Skip to content

stack: start fails on Linux when the host firewall drops input (ufw default): containers cannot reach the CLI's host listener #7857

Backlog

Description

@smk762

Affected area

Local development

Supabase CLI version

3.4.0

Operating system

Ubuntu 26.04 LTS (x64), ufw enabled with its default incoming policy (DROP)

Installation method

Other (npx supabase@3.4.0)

Command

SUPABASE_EXPERIMENTAL_STACK=1 supabase start -x functions,studio,mail,analytics,pooler

Actual output

Fails after 35 to 55 seconds. Reproduced twice.

[task] start: Starting local Supabase stack...
[task] failed: realtime.initialize exited with code 1
stdout:
Running Realtime migrations
Migrating and seeding selfhosted Realtime in one BEAM
[error] Could not create schema migrations table. This error usually happens due to the following:
  * The database does not exist
  * The "schema_migrations" table, which Ecto uses for managing
    migrations, was defined by another library
  * There is a deadlock while migrating (such as using concurrent
    indexes with a migration_lock)
To fix the first issue, run "mix ecto.create" for the desired MIX_ENV.
...
[error] Postgrex.Protocol (#PID<0.152.0> ("db_conn_2")) failed to connect: ** (DBConnection.ConnectionError) tcp connect (host.supabase.internal:24297): timeout
stderr:
** (DBConnection.ConnectionError) [Elixir.Realtime.Repo] connection not available and request was dropped from queue after 14992ms.
...
{"_tag":"Error","error":{"code":"ExperimentalStackStartError","message":"realtime.initialize exited with code 1 ..."}}

Expected behavior

The stack starts, as the default supabase start does on the same machine with the same config. Failing that, an error that names the unreachable host port and the likely firewall cause.

Steps to reproduce

  1. Ubuntu with Docker Engine (not Docker Desktop) and ufw enabled with the default incoming policy (DEFAULT_INPUT_POLICY="DROP" in /etc/default/ufw), with no rule admitting traffic from the Docker bridge.
  2. In a project with a supabase/ directory and no fixed ports in its config, run the command above.

Docker and service versions

Docker Engine 29.5.2. Resolved by the CLI: database 17.12.0.002-r0, rest v16.6-r0, auth v2.198.0-r0, realtime v2.177.1-r0, storage v1.98.8-r0. Runtime: docker.

Additional context

Cause (confirmed): the host firewall drops the containers' connections to the CLI's listener.

  • During the start, the supabase process itself listens on the host. ss -ltnp shows 0.0.0.0:24297 users:(("supabase",…)) and two more ports.
  • The service containers are on Docker's default bridge network and connect to that listener at the bridge gateway (host.supabase.internal resolves to 172.17.0.1).
  • That is input to a host process, so the host's INPUT policy applies. The kernel log has one entry per attempt, at the second of the failure, on the port named in the error:
    [UFW BLOCK] IN=docker0 OUT= SRC=172.17.0.5 DST=172.17.0.1 PROTO=TCP SPT=33520 DPT=24297 SYN
    [UFW BLOCK] IN=docker0 OUT= SRC=172.17.0.7 DST=172.17.0.1 PROTO=TCP SPT=39724 DPT=24297 SYN
    [UFW BLOCK] IN=docker0 OUT= SRC=172.17.0.8 DST=172.17.0.1 PROTO=TCP SPT=58984 DPT=24297 SYN
    
  • A second run was assigned port 32399 and produced the same entries for that port.
  • The default stack is unaffected: its containers talk over a Docker network, and Docker-published ports are not subject to the INPUT chain.

Fix confirmed. With one rule added,

sudo ufw allow in on docker0 from 172.17.0.0/16 to 172.17.0.1 port 20000:32767 proto tcp

the same command reached Stack is ready in 34 seconds, and the kernel log has no [UFW BLOCK] entry on docker0 for that run. Without the rule the start failed twice; with it, it succeeded.

Why it matters. ufw with incoming denied is a common Ubuntu setup, and it is what a user enables to protect a development machine.

Feedback on the failure itself

  1. The message points the wrong way. The first lines are Ecto's advice to run mix ecto.create. The timeout to host.supabase.internal:<port> is some twenty lines down, and nothing mentions a firewall.
  2. Only Realtime is blamed. Three containers were blocked on the same port. The report names one, which suggests a Realtime bug (compare stack: realtime fails to start on Docker Desktop because it connects to host.docker.internal over IPv6 #6775: the same symptom, a different cause).
  3. It takes 35 to 55 seconds to fail. A connectivity check from a container to the host listener before starting services would fail in a second with a precise message.
  4. The guide does not mention firewalls. "Running multiple local projects" lists limitations but not this one.
  5. The failed stack stays registered. supabase stack list still shows it with no containers running, and the next step (retry, or stack destroy) is not suggested.
  6. A tracked file is edited silently. The start prints Created supabase/supabase.lock. but also appends four lines to supabase/.gitignore without saying so, and stack destroy leaves supabase/.supabase.lock.lease behind.

Suggestions

  • Put the stack's containers on a Docker network and connect them directly where the runtime is Docker, as the default stack does.
  • Or probe the host listener from a container first, and on a timeout say that containers cannot reach the host on port N and that a host firewall may be dropping traffic from the Docker bridge, with the rule above as the fix.
  • Document the requirement in the guide.

Related: #6775 (closed) had the same Realtime symptom on Docker Desktop, caused by IPv6. This is Docker Engine on Linux over IPv4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions