Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
1.02k
stars
201
forks
source link
Connecting to localhost from within the db container not working #2022
Closed
supermar1010 closed 6 months ago
Describe the bug
Connecting to the docker host from the postgresql via pg_net is not possible.
To Reproduce Steps to reproduce the behavior:
supabase start
to start the local dev envselect net.http_get('http://host.docker.internal:3000/');
Expected behavior
I expected to be able to connect to localhost from inside the db container.
System information Rerun the failing command with
--create-ticket
flag (preferred).SERVICE IMAGE │ LOCAL │ LINKED ─────────────────────────┼──────────────────────┼───────── supabase/postgres │ 15.1.0.117 │ - supabase/gotrue │ v2.125.1 │ - postgrest/postgrest │ v11.2.2 │ - supabase/realtime │ v2.25.35 │ - supabase/storage-api │ v0.43.11 │ - supabase/edge-runtime │ v1.29.1 │ - supabase/studio │ 20231123-64a766a │ - supabase/postgres-meta │ v0.75.0 │ - supabase/logflare │ 1.4.0 │ - bitnami/pgbouncer │ 1.20.1-debian-11-r39 │ - darthsim/imgproxy │ v3.8.0 │ -
I tried debugging this myself: I had a look here (https://github.com/supabase/cli/blob/b0082f9983cb64f90f0714e8807389f6a1f1ff58/internal/db/start/start.go#L103) to see how the db docker container is configured.
I noticed that it is missing the NetworkMode: 'host'. The gen types command has this param, and has no problems connecting to localhost (https://github.com/supabase/cli/blob/b0082f9983cb64f90f0714e8807389f6a1f1ff58/internal/gen/types/typescript/typescript.go#L76).
I also tried compiling myself to add this param, but I always end up getting an error message, because the docker daemon couldn't find the network.