supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.08k stars 209 forks source link

Supabase db diff fails to connect to database #1625

Closed gilbert closed 9 months ago

gilbert commented 1 year ago

Bug Report

Describe the bug

Running supabase db diff throws a "failed to connect" error:

failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp 127.0.0.1:54320: connect: connection refused)

To Reproduce

Steps to reproduce the behavior:

  1. Run supabase db reset
  2. Make a change via the web ui (optional)
  3. Run supabase db diff
  4. See error

Expected behavior

Produce output as the command usually would.

System Info

Additional context

In case it's helpful: When I run docker ps in another terminal while running supabase db diff, during its Creating shadow database... output / waiting time, I can see the target process running:

3189bce66164   public.ecr.aws/supabase/postgres:15.1.0.117       "sh -c 'cat <<'EOF' …"   1 second ago   Up Less than a second (health: starting)   0.0.0.0:54320->5432/tcp, :::54320->5432/tcp

Here's the full debug output:

Full debug output ``` % supabase db diff --debug | pbcopy Supabase CLI 1.106.1 Connecting to local database... 2023/10/29 15:31:35 Connect Start: tcp [::1]:54322 2023/10/29 15:31:35 Connect Error: tcp [::1]:54322 dial tcp [::1]:54322: connect: connection refused 2023/10/29 15:31:35 Connect Start: tcp 127.0.0.1:54322 2023/10/29 15:31:35 Connect Done: tcp 127.0.0.1:54322 2023/10/29 15:31:35 PG Send: {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"database":"postgres","user":"postgres"}} 2023/10/29 15:31:35 PG Recv: {"Type":"AuthenticationSASL","AuthMechanisms":["SCRAM-SHA-256"]} 2023/10/29 15:31:35 PG Send: {"Type":"SASLInitialResponse","AuthMechanism":"SCRAM-SHA-256","Data":"n,,n=,r=wXSRHl7QZKN1F7h9VxR3g9EW"} 2023/10/29 15:31:35 PG Recv: {"Type":"AuthenticationSASLContinue","Data":"r=wXSRHl7QZKN1F7h9VxR3g9EWGFxi27bdYXvKRBGoN+ihfZ5F,s=V6sB21EybtDJi/QvHZevGQ==,i=4096"} 2023/10/29 15:31:35 PG Send: {"Type":"SASLResponse","Data":"c=biws,r=wXSRHl7QZKN1F7h9VxR3g9EWGFxi27bdYXvKRBGoN+ihfZ5F,p=Gpu1pmTIJ78DWushWXy27fSDZtrv0Ms8RgPSIZdkDng="} 2023/10/29 15:31:35 PG Recv: {"Type":"AuthenticationSASLFinal","Data":"v=Km4X5HTphFn4pCOkMM0/ALXoTVwDjmhHQ00yh3hb+v4="} 2023/10/29 15:31:35 PG Recv: {"Type":"AuthenticationOK"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"application_name","Value":""} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"default_transaction_read_only","Value":"off"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"in_hot_standby","Value":"off"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"is_superuser","Value":"off"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"server_version","Value":"15.1 (Ubuntu 15.1-1.pgdg20.04+1)"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"session_authorization","Value":"postgres"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterStatus","Name":"TimeZone","Value":"UTC"} 2023/10/29 15:31:35 PG Recv: {"Type":"BackendKeyData","ProcessID":16432,"SecretKey":1954759019} 2023/10/29 15:31:35 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"} 2023/10/29 15:31:35 PG Send: {"Type":"Parse","Name":"lrupsc_1_0","Query":"SELECT schema_name FROM information_schema.schemata WHERE NOT schema_name LIKE ANY($1) ORDER BY schema_name","ParameterOIDs":null} 2023/10/29 15:31:35 PG Send: {"Type":"Describe","ObjectType":"S","Name":"lrupsc_1_0"} 2023/10/29 15:31:35 PG Send: {"Type":"Sync"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParseComplete"} 2023/10/29 15:31:35 PG Recv: {"Type":"ParameterDescription","ParameterOIDs":[1009]} 2023/10/29 15:31:35 PG Recv: {"Type":"RowDescription","Fields":[{"Name":"schema_name","TableOID":13330,"TableAttributeNumber":2,"DataTypeOID":19,"DataTypeSize":64,"TypeModifier":-1,"Format":0}]} 2023/10/29 15:31:35 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"} 2023/10/29 15:31:35 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"lrupsc_1_0","ParameterFormatCodes":[1],"Parameters":[{"binary":"00000001000000000000001900000018000000010000000461757468000000097067626f756e636572000000087265616c74696d650000000a5c5f7265616c74696d650000000773746f726167650000000b5c5f616e616c79746963730000001373757061626173655c5f66756e6374696f6e730000001473757061626173655c5f6d6967726174696f6e7300000013696e666f726d6174696f6e5c5f736368656d610000000570675c5f250000000463726f6e000000076772617068716c0000000f6772617068716c5c5f7075626c6963000000036e6574000000087067736f6469756d0000000f7067736f6469756d5c5f6d61736b73000000057067746c650000000672657061636b0000000574696765720000000b74696765725c5f646174610000000e74696d657363616c6564625c5f25000000105c5f74696d657363616c6564625c5f2500000008746f706f6c6f6779000000057661756c74"}],"ResultFormatCodes":[1]} 2023/10/29 15:31:35 PG Send: {"Type":"Describe","ObjectType":"P","Name":""} 2023/10/29 15:31:35 PG Send: {"Type":"Execute","Portal":"","MaxRows":0} 2023/10/29 15:31:35 PG Send: {"Type":"Sync"} 2023/10/29 15:31:35 PG Recv: {"Type":"BindComplete"} 2023/10/29 15:31:35 PG Recv: {"Type":"RowDescription","Fields":[{"Name":"schema_name","TableOID":13330,"TableAttributeNumber":2,"DataTypeOID":19,"DataTypeSize":64,"TypeModifier":-1,"Format":1}]} 2023/10/29 15:31:35 PG Recv: {"Type":"DataRow","Values":[{"text":"app_admin"}]} 2023/10/29 15:31:35 PG Recv: {"Type":"DataRow","Values":[{"text":"dramatiq"}]} 2023/10/29 15:31:35 PG Recv: {"Type":"DataRow","Values":[{"text":"extensions"}]} 2023/10/29 15:31:35 PG Recv: {"Type":"DataRow","Values":[{"text":"public"}]} 2023/10/29 15:31:35 PG Recv: {"Type":"CommandComplete","CommandTag":"SELECT 4"} 2023/10/29 15:31:35 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"} Creating shadow database... 2023/10/29 15:31:35 PG Send: {"Type":"Terminate"} 2023/10/29 15:31:35 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:35 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:35 Send Done 2023/10/29 15:31:35 Recv First Byte 2023/10/29 15:31:35 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:35 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:35 Sent Header: Content-Length [306] 2023/10/29 15:31:35 Sent Header: Content-Type [application/json] 2023/10/29 15:31:35 Send Done 2023/10/29 15:31:35 Recv First Byte 2023/10/29 15:31:35 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:35 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:35 Sent Header: Content-Length [11863] 2023/10/29 15:31:35 Sent Header: Content-Type [application/json] 2023/10/29 15:31:35 Send Done 2023/10/29 15:31:35 Recv First Byte 2023/10/29 15:31:35 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:35 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:35 Sent Header: Content-Length [0] 2023/10/29 15:31:35 Sent Header: Content-Type [text/plain] 2023/10/29 15:31:35 Send Done 2023/10/29 15:31:36 Recv First Byte 2023/10/29 15:31:36 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:36 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:36 Send Done 2023/10/29 15:31:36 Recv First Byte 2023/10/29 15:31:37 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:37 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:37 Send Done 2023/10/29 15:31:37 Recv First Byte 2023/10/29 15:31:38 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:38 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:38 Send Done 2023/10/29 15:31:38 Recv First Byte 2023/10/29 15:31:39 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:39 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:39 Send Done 2023/10/29 15:31:39 Recv First Byte 2023/10/29 15:31:40 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:40 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:40 Send Done 2023/10/29 15:31:40 Recv First Byte 2023/10/29 15:31:41 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:41 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:41 Send Done 2023/10/29 15:31:41 Recv First Byte 2023/10/29 15:31:42 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:42 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:42 Send Done 2023/10/29 15:31:42 Recv First Byte 2023/10/29 15:31:43 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:43 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:43 Send Done 2023/10/29 15:31:43 Recv First Byte 2023/10/29 15:31:44 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:44 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:44 Send Done 2023/10/29 15:31:44 Recv First Byte 2023/10/29 15:31:45 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:45 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:45 Send Done 2023/10/29 15:31:45 Recv First Byte 2023/10/29 15:31:46 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:46 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:46 Send Done 2023/10/29 15:31:46 Recv First Byte 2023/10/29 15:31:47 Sent Header: Host [api.moby.localhost] 2023/10/29 15:31:47 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)] 2023/10/29 15:31:47 Send Done 2023/10/29 15:31:47 Recv First Byte 2023/10/29 15:31:47 Connect Start: tcp [::1]:54320 2023/10/29 15:31:47 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:47 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:47 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:47 Connect Start: tcp [::1]:54320 2023/10/29 15:31:47 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:47 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:47 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:48 Connect Start: tcp [::1]:54320 2023/10/29 15:31:48 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:48 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:48 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:48 Connect Start: tcp [::1]:54320 2023/10/29 15:31:48 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:48 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:48 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:49 Connect Start: tcp [::1]:54320 2023/10/29 15:31:49 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:49 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:49 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:49 Connect Start: tcp [::1]:54320 2023/10/29 15:31:49 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:49 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:49 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:50 Connect Start: tcp [::1]:54320 2023/10/29 15:31:50 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:50 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:50 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:50 Connect Start: tcp [::1]:54320 2023/10/29 15:31:50 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:50 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:50 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:51 Connect Start: tcp [::1]:54320 2023/10/29 15:31:51 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:51 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:51 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:51 Connect Start: tcp [::1]:54320 2023/10/29 15:31:51 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:51 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:51 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:52 Connect Start: tcp [::1]:54320 2023/10/29 15:31:52 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:52 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:52 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:52 Connect Start: tcp [::1]:54320 2023/10/29 15:31:52 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:52 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:52 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:53 Connect Start: tcp [::1]:54320 2023/10/29 15:31:53 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:53 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:53 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:53 Connect Start: tcp [::1]:54320 2023/10/29 15:31:53 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:53 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:53 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:54 Connect Start: tcp [::1]:54320 2023/10/29 15:31:54 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:54 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:54 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:54 Connect Start: tcp [::1]:54320 2023/10/29 15:31:54 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:54 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:54 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:55 Connect Start: tcp [::1]:54320 2023/10/29 15:31:55 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:55 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:55 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:55 Connect Start: tcp [::1]:54320 2023/10/29 15:31:55 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:55 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:55 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:56 Connect Start: tcp [::1]:54320 2023/10/29 15:31:56 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:56 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:56 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused 2023/10/29 15:31:56 Connect Start: tcp [::1]:54320 2023/10/29 15:31:56 Connect Error: tcp [::1]:54320 dial tcp [::1]:54320: connect: connection refused 2023/10/29 15:31:56 Connect Start: tcp 127.0.0.1:54320 2023/10/29 15:31:56 Connect Error: tcp 127.0.0.1:54320 dial tcp 127.0.0.1:54320: connect: connection refused failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp 127.0.0.1:54320: connect: connection refused) ```
sweatybridge commented 1 year ago

To help us debug, could you produce the logs from 3189bce66164 container while supabase db diff is running?

gilbert commented 1 year ago

Here you go:

% docker ps
CONTAINER ID   IMAGE                                             COMMAND                  CREATED         STATUS                            PORTS                                                                                                                                   NAMES
98890b01c110   public.ecr.aws/supabase/postgres:15.1.0.117       "sh -c 'cat <<'EOF' …"   3 seconds ago   Up 2 seconds (health: starting)   0.0.0.0:54320->5432/tcp, :::54320->5432/tcp
% docker logs --follow 98890b01c110 ``` % docker logs --follow 98890b01c110 The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with this locale configuration: provider: libc LC_COLLATE: C.UTF-8 LC_CTYPE: C.UTF-8 LC_MESSAGES: en_US.UTF-8 LC_MONETARY: en_US.UTF-8 LC_NUMERIC: en_US.UTF-8 LC_TIME: en_US.UTF-8 The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Etc/UTC creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/data -l logfile start initdb: warning: enabling "trust" authentication for local connections initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. waiting for server to start.... 2023-11-10 01:12:51.261 UTC [53] LOG: pgaudit extension initialized 2023-11-10 01:12:51.266 UTC [53] LOG: pgsodium primary server secret key loaded 2023-11-10 01:12:51.284 UTC [53] LOG: starting PostgreSQL 15.1 (Ubuntu 15.1-1.pgdg20.04+1) on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit 2023-11-10 01:12:51.286 UTC [53] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-11-10 01:12:51.289 UTC [59] LOG: database system was shut down at 2023-11-10 01:12:50 UTC 2023-11-10 01:12:51.294 UTC [53] LOG: database system is ready to accept connections 2023-11-10 01:12:51.295 UTC [62] LOG: TimescaleDB background worker launcher connected to shared catalogs 2023-11-10 01:12:51.298 UTC [64] LOG: pg_cron scheduler started done server started /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/init-scripts /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/migrate.sh /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/init-scripts/00-schema.sql CREATE ROLE REVOKE CREATE SCHEMA CREATE FUNCTION REVOKE GRANT /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/init-scripts/00000000000000-initial-schema.sql CREATE PUBLICATION CREATE ROLE ALTER ROLE CREATE ROLE CREATE ROLE GRANT ROLE CREATE SCHEMA CREATE EXTENSION CREATE EXTENSION CREATE EXTENSION CREATE ROLE CREATE ROLE CREATE ROLE CREATE ROLE GRANT ROLE GRANT ROLE GRANT ROLE GRANT ROLE GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES GRANT ALTER ROLE ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER ROLE ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/init-scripts/00000000000001-auth-schema.sql CREATE SCHEMA CREATE TABLE CREATE INDEX CREATE INDEX COMMENT CREATE TABLE CREATE INDEX CREATE INDEX CREATE INDEX COMMENT CREATE TABLE COMMENT CREATE TABLE CREATE INDEX COMMENT CREATE TABLE COMMENT INSERT 0 7 CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION GRANT CREATE ROLE GRANT GRANT GRANT ALTER ROLE ALTER TABLE ALTER TABLE ALTER TABLE ALTER TABLE ALTER TABLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/init-scripts/00000000000002-storage-schema.sql CREATE SCHEMA GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES CREATE TABLE CREATE INDEX CREATE TABLE CREATE INDEX CREATE INDEX ALTER TABLE CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE TABLE CREATE ROLE GRANT GRANT GRANT ALTER ROLE ALTER TABLE ALTER TABLE ALTER TABLE ALTER FUNCTION ALTER FUNCTION ALTER FUNCTION ALTER FUNCTION /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/init-scripts/00000000000003-post-setup.sql ALTER ROLE ALTER ROLE CREATE FUNCTION CREATE EVENT TRIGGER COMMENT CREATE FUNCTION COMMENT DO CREATE ROLE GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/00-extension.sql psql:/docker-entrypoint-initdb.d/migrations/00-extension.sql:1: NOTICE: schema "extensions" already exists, skipping CREATE SCHEMA CREATE EXTENSION /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/10000000000000_demote-postgres.sql GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20211115181400_update-auth-permissions.sql GRANT GRANT GRANT ALTER TABLE ALTER TABLE ALTER TABLE ALTER TABLE ALTER TABLE GRANT GRANT GRANT GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20211118015519_create-realtime-schema.sql CREATE SCHEMA /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20211122051245_update-realtime-permissions.sql GRANT GRANT GRANT GRANT /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20211124212715_update-auth-owner.sql ALTER FUNCTION ALTER FUNCTION ALTER FUNCTION /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20211130151719_update-realtime-permissions.sql ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220118070449_enable-safeupdate-postgrest.sql ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220126121436_finer-postgrest-triggers.sql psql:/docker-entrypoint-initdb.d/migrations/20220126121436_finer-postgrest-triggers.sql:3: NOTICE: event trigger "api_restart" does not exist, skipping DROP EVENT TRIGGER psql:/docker-entrypoint-initdb.d/migrations/20220126121436_finer-postgrest-triggers.sql:4: NOTICE: function extensions.notify_api_restart() does not exist, skipping DROP FUNCTION CREATE FUNCTION CREATE FUNCTION psql:/docker-entrypoint-initdb.d/migrations/20220126121436_finer-postgrest-triggers.sql:59: NOTICE: event trigger "pgrst_ddl_watch" does not exist, skipping DROP EVENT TRIGGER CREATE EVENT TRIGGER psql:/docker-entrypoint-initdb.d/migrations/20220126121436_finer-postgrest-triggers.sql:64: NOTICE: event trigger "pgrst_drop_watch" does not exist, skipping DROP EVENT TRIGGER CREATE EVENT TRIGGER /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220224211803_fix-postgrest-supautils.sql DO /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220317095840_pg_graphql.sql CREATE SCHEMA CREATE FUNCTION GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES CREATE FUNCTION psql:/docker-entrypoint-initdb.d/migrations/20220317095840_pg_graphql.sql:88: NOTICE: event trigger "issue_pg_graphql_access" does not exist, skipping DROP EVENT TRIGGER CREATE EVENT TRIGGER COMMENT CREATE FUNCTION psql:/docker-entrypoint-initdb.d/migrations/20220317095840_pg_graphql.sql:141: NOTICE: event trigger "issue_graphql_placeholder" does not exist, skipping DROP EVENT TRIGGER CREATE EVENT TRIGGER COMMENT /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220321174452_fix-postgrest-alter-type-event-trigger.sql psql:/docker-entrypoint-initdb.d/migrations/20220321174452_fix-postgrest-alter-type-event-trigger.sql:3: NOTICE: event trigger "api_restart" does not exist, skipping DROP EVENT TRIGGER psql:/docker-entrypoint-initdb.d/migrations/20220321174452_fix-postgrest-alter-type-event-trigger.sql:4: NOTICE: function extensions.notify_api_restart() does not exist, skipping DROP FUNCTION CREATE FUNCTION CREATE FUNCTION DROP EVENT TRIGGER CREATE EVENT TRIGGER DROP EVENT TRIGGER CREATE EVENT TRIGGER /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220322085208_gotrue-session-limit.sql ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220404205710_pg_graphql-on-by-default.sql CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION psql:/docker-entrypoint-initdb.d/migrations/20220404205710_pg_graphql-on-by-default.sql:142: NOTICE: extension "pg_graphql" does not exist, skipping DROP EXTENSION DO /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220609081115_grant-supabase-auth-admin-and-supabase-storage-admin-to-postgres.sql GRANT ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220613123923_pg_graphql-pg-dump-perms.sql CREATE FUNCTION DROP EXTENSION DO /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20220713082019_pg_cron-pg_net-temp-perms-fix.sql DO DO /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20221028101028_set_authenticator_timeout.sql ALTER ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20221103090837_revoke_admin.sql REVOKE ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20221207154255_create_pgsodium_and_vault.sql DO /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20230201083204_grant_auth_roles_to_postgres.sql GRANT ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20230224042246_grant_extensions_perms_for_postgres.sql GRANT GRANT GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20230306081037_grant_pg_monitor_to_postgres.sql GRANT ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20230327032006_grant_auth_roles_to_supabase_storage_admin.sql GRANT ROLE /docker-entrypoint-initdb.d/migrate.sh: running /docker-entrypoint-initdb.d/migrations/20230529180330_alter_api_roles_for_inherit.sql ALTER ROLE ALTER ROLE ALTER ROLE GRANT ROLE /docker-entrypoint-initdb.d/migrate.sh: running /etc/postgresql.schema.sql ALTER DATABASE ALTER DATABASE ALTER ROLE ALTER ROLE ALTER ROLE ALTER ROLE ALTER ROLE ALTER ROLE CREATE SCHEMA ALTER SCHEMA CREATE SCHEMA ALTER SCHEMA BEGIN CREATE EXTENSION CREATE SCHEMA GRANT ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES CREATE TABLE INSERT 0 1 CREATE TABLE CREATE INDEX CREATE INDEX COMMENT CREATE FUNCTION DO GRANT GRANT GRANT ALTER ROLE ALTER TABLE ALTER TABLE ALTER FUNCTION GRANT ROLE DO DO CREATE FUNCTION COMMENT DO INSERT 0 1 ALTER FUNCTION ALTER FUNCTION REVOKE GRANT COMMIT pg_stat_statements_reset -------------------------- (1 row) pg_stat_reset --------------- (1 row) /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/migrations waiting for server to shut down... 2023-11-10 01:12:52.380 UTC [53] LOG: received fast shutdown request . 2023-11-10 01:12:52.381 UTC [53] LOG: aborting any active transactions 2023-11-10 01:12:52.381 UTC [64] LOG: pg_cron scheduler shutting down 2023-11-10 01:12:52.381 UTC [62] FATAL: terminating background worker "TimescaleDB Background Worker Launcher" due to administrator command 2023-11-10 01:12:52.383 UTC [53] LOG: background worker "logical replication launcher" (PID 65) exited with exit code 1 2023-11-10 01:12:52.389 UTC [53] LOG: background worker "TimescaleDB Background Worker Launcher" (PID 62) exited with exit code 1 2023-11-10 01:12:52.391 UTC [57] LOG: shutting down 2023-11-10 01:12:52.393 UTC [57] LOG: checkpoint starting: shutdown immediate 2023-11-10 01:12:52.432 UTC [57] LOG: checkpoint complete: wrote 358 buffers (2.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.033 s, total=0.042 s; sync files=123, longest=0.001 s, average=0.001 s; distance=2921 kB, estimate=2921 kB 2023-11-10 01:12:52.441 UTC [53] LOG: database system is shut down done server stopped PostgreSQL init process complete; ready for start up. 2023-11-10 01:12:52.491 UTC [10] LOG: pgaudit extension initialized 2023-11-10 01:12:52.496 UTC [10] LOG: pgsodium primary server secret key loaded 2023-11-10 01:12:52.514 UTC [10] LOG: starting PostgreSQL 15.1 (Ubuntu 15.1-1.pgdg20.04+1) on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit 2023-11-10 01:12:52.514 UTC [10] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-11-10 01:12:52.514 UTC [10] LOG: listening on IPv6 address "::", port 5432 2023-11-10 01:12:52.515 UTC [10] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-11-10 01:12:52.518 UTC [149] LOG: database system was shut down at 2023-11-10 01:12:52 UTC 2023-11-10 01:12:52.522 UTC [10] LOG: database system is ready to accept connections 2023-11-10 01:12:52.524 UTC [152] LOG: TimescaleDB background worker launcher connected to shared catalogs 2023-11-10 01:12:52.526 UTC [154] LOG: pg_cron scheduler started ```
ibilalkayy commented 11 months ago

This is the same problem that I faced but after uninstalling supabase and installing again, it finally got resolved.

gregkeys-fideseo commented 11 months ago

uninstalling and reinstalling did not work for me

WA-WilliamKrieg commented 10 months ago

it's the same probleme for me, not changes after uninstalling and reinstalling :/

ghost commented 9 months ago

I'm experiencing this too... any updates @sweatybridge ?

Edit:

I am able to run supabase db push no problem; here's my stack dump from running supabase db diff --linked -f diff (the initial connection to the remote database succeeds, but then fails on the step trying to diff the schemas):

supabase db diff --linked -f diff
Connecting to remote database...
Creating shadow database...
Setting up initial schema...
Applying migration 20240129203320_diff.sql...
Applying migration 20240129224506_diff.sql...
Applying migration 20240129224939_diff.sql...
Applying migration 20240129225049_diff.sql...
Applying migration 20240129225949_diff.sql...
Applying migration 20240129230626_diff.sql...
Applying migration 20240129233053_diff.sql...
Applying migration 20240129233215_diff.sql...
Applying migration 20240129234646_diff.sql...
Applying migration 20240129234905_diff.sql...
Applying migration 20240129235646_diff.sql...
Applying migration 20240130052914_diff.sql...
Diffing schemas: extensions,public
error diffing schema: error running container: exit 1:                                                                                                                                                     
Traceback (most recent call last):                                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 9, in connection_from_s_or_c                                                                                                   
    s_or_c.engine                                                                                                                                                                                          
AttributeError: 'Session' object has no attribute 'engine'                                                                                                                                                 

During handling of the above exception, another exception occurred:                                                                                                                                        

Traceback (most recent call last):                                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in __init__                                                                                                           
    self._dbapi_connection = engine.raw_connection()                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection                                                                                                    
    return self.pool.connect()                                                                                                                                                                             
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect                                                                                                              
    return _ConnectionFairy._checkout(self)                                                                                                                                                                
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout                                                                                                           
    fairy = _ConnectionRecord.checkout(pool)                                                                                                                                                               
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 716, in checkout                                                                                                             
    rec = pool._do_get()                                                                                                                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 170, in _do_get                                                                                                              
    self._dec_overflow()                                                                                                                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                                                                                                      
    raise exc_value.with_traceback(exc_tb)                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get                                                                                                              
    return self._create_connection()                                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection                                                                                                   
    return _ConnectionRecord(self)                                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 678, in __init__                                                                                                             
    self.__connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 903, in __connect                                                                                                            
    pool.logger.debug("Error on connect(): %s", e)                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                                                                                                      
    raise exc_value.with_traceback(exc_tb)                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 898, in __connect                                                                                                            
    self.dbapi_connection = connection = pool._invoke_creator(self)                                                                                                                                        
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 645, in connect                                                                                                          
    return dialect.connect(*cargs, **cparams)                                                                                                                                                              
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 616, in connect                                                                                                         
    return self.loaded_dbapi.connect(*cargs, **cparams)                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect                                                                                                                 
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)                                                                                                                                 
psycopg2.OperationalError: connection to server at "db.echqtnprrbihnlvckhyw.supabase.co" (2600:1f18:2e13:9d04:b2e2:a45d:c0cf:71db), port 5432 failed: Network unreachable                                  
    Is the server running on that host and accepting TCP/IP connections?                                                                                                                                   

The above exception was the direct cause of the following exception:                                                                                                                                       

Traceback (most recent call last):                                                                                                                                                                         
  File "/usr/local/bin/migra", line 8, in <module>                                                                                                                                                         
    sys.exit(do_command())                                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 121, in do_command                                                                                                                  
    status = run(args)                                                                                                                                                                                     
  File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 86, in run                                                                                                                          
    m = Migration(                                                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/migra/migra.py", line 39, in __init__                                                                                                                       
    self.changes.i_target = get_inspector(                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/schemainspect/get.py", line 14, in get_inspector                                                                                                            
    c = connection_from_s_or_c(x)                                                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 14, in connection_from_s_or_c                                                                                                  
    return s_or_c.connection()                                                                                                                                                                             
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2031, in connection                                                                                                        
    return self._connection_for_bind(                                                                                                                                                                      
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2047, in _connection_for_bind                                                                                              
    return trans._connection_for_bind(engine, execution_options)                                                                                                                                           
  File "<string>", line 2, in _connection_for_bind                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go                                                                                                          
    ret_value = fn(self, *arg, **kw)                                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1143, in _connection_for_bind                                                                                              
    conn = bind.connect()                                                                                                                                                                                  
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3269, in connect                                                                                                           
    return self._connection_cls(self)                                                                                                                                                                      
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 147, in __init__                                                                                                           
    Connection._handle_dbapi_exception_noconnection(                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2431, in _handle_dbapi_exception_noconnection                                                                              
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in __init__                                                                                                           
    self._dbapi_connection = engine.raw_connection()                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection                                                                                                    
    return self.pool.connect()                                                                                                                                                                             
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect                                                                                                              
    return _ConnectionFairy._checkout(self)                                                                                                                                                                
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout                                                                                                           
    fairy = _ConnectionRecord.checkout(pool)                                                                                                                                                               
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 716, in checkout                                                                                                             
    rec = pool._do_get()                                                                                                                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 170, in _do_get                                                                                                              
    self._dec_overflow()                                                                                                                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                                                                                                      
    raise exc_value.with_traceback(exc_tb)                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get                                                                                                              
    return self._create_connection()                                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection                                                                                                   
    return _ConnectionRecord(self)                                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 678, in __init__                                                                                                             
    self.__connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 903, in __connect                                                                                                            
    pool.logger.debug("Error on connect(): %s", e)                                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                                                                                                      
    raise exc_value.with_traceback(exc_tb)                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 898, in __connect                                                                                                            
    self.dbapi_connection = connection = pool._invoke_creator(self)                                                                                                                                        
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 645, in connect                                                                                                          
    return dialect.connect(*cargs, **cparams)                                                                                                                                                              
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 616, in connect                                                                                                         
    return self.loaded_dbapi.connect(*cargs, **cparams)                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect                                                                                                                 
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)                                                                                                                                 
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db.echqtnprrbihnlvckhyw.supabase.co" (2600:1f18:2e13:9d04:b2e2:a45d:c0cf:71db), port 5432 failed: Network unreachable
    Is the server running on that host and accepting TCP/IP connections?                                                                                                                                   

(Background on this error at: https://sqlalche.me/e/20/e3q8)   
sweatybridge commented 9 months ago

Seems like migra cannot connect to IPv6 address. I will take a closer look today

honeybread commented 9 months ago

Is there a way around while this gets worked out?

ghost commented 9 months ago

@honeybread they just use migra under the hood, so if it's a huge road block, you could just use the connection strings for your local and remote supabase instances and manually invoke migra: https://github.com/djrobstep/migra

honeybread commented 9 months ago

@nbarrow-inspire-labs thank you!

sweatybridge commented 9 months ago

Is there a way around while this gets worked out?

Yes the workaround is to pass in the pooler url via --db-url flag which resolves to IPv4 address.

simicvm commented 9 months ago

Is there a way around while this gets worked out?

Yes the workaround is to pass in the pooler url via --db-url flag which resolves to IPv4 address.

got the same error on db pull today. ~this solved it.~

spoke too soon, now I have this issue: https://github.com/supabase/cli/issues/1574

updated the cli to the newest version. still an issue, although error message a bit more verbose.

system: System Version: macOS 14.3 (23D56) Kernel Version: Darwin 23.3.0

sweatybridge commented 9 months ago

This should be resolved in beta release v1.141.2

npx supabase@beta db pull
simicvm commented 9 months ago

This should be resolved in beta release v1.141.2

npx supabase@beta db pull

maybe I am doing something wrong, but neither npx supabase@beta db pull nor npx supabase@beta db pull --db-url postgres://... work for me.

sweatybridge commented 9 months ago

@simicvm do you mind sharing the logs with --debug flag?

simicvm commented 9 months ago

@sweatybridge 👍

npx supabase@beta db pull --debug --db-url postgres://... This one manages to connect and authenticate but fails during migration. Output bellow is only the last part before the error, the whole thing has more than 1000 lines.

2024/02/02 18:26:39 Sent Header: Host [api.moby.localhost]
2024/02/02 18:26:39 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:26:39 Send Done
2024/02/02 18:26:39 Recv First Byte
2024/02/02 18:26:39 Sent Header: Host [api.moby.localhost]
2024/02/02 18:26:39 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:26:39 Sent Header: Content-Length [2524]
2024/02/02 18:26:39 Sent Header: Content-Type [application/json]
2024/02/02 18:26:39 Send Done
2024/02/02 18:26:39 Recv First Bytec
2024/02/02 18:26:39 Sent Header: Host [api.moby.localhost]
2024/02/02 18:26:39 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:26:39 Sent Header: Content-Length [0]
2024/02/02 18:26:39 Sent Header: Content-Type [text/plain]
2024/02/02 18:26:39 Send Done
2024/02/02 18:26:39 Recv First Byte
2024/02/02 18:26:39 Sent Header: Host [api.moby.localhost]
2024/02/02 18:26:39 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:26:39 Send Done
2024/02/02 18:26:39 Recv First Byte
2024/02/02 18:26:51 Sent Header: Host [api.moby.localhost]
2024/02/02 18:26:51 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:26:51 Send Done
2024/02/02 18:26:51 Recv First Byte
2024/02/02 18:26:51 PG Send: {"Type":"Terminate"}
error diffing schema: error running container: exit 1:                                                                       
Traceback (most recent call last):                                                                                           
  File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 9, in connection_from_s_or_c                     
    s_or_c.engine                                                                                                            
AttributeError: 'Session' object has no attribute 'engine'                                                                   

During handling of the above exception, another exception occurred:                                                          

Traceback (most recent call last):                                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in __init__                             
    self._dbapi_connection = engine.raw_connection()                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection                      
    return self.pool.connect()                                                                                               
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect                                
    return _ConnectionFairy._checkout(self)                                                                                  
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout                             
    fairy = _ConnectionRecord.checkout(pool)                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 716, in checkout                               
    rec = pool._do_get()                                                                                                     
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 170, in _do_get                                
    self._dec_overflow()                                                                                                     
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                        
    raise exc_value.with_traceback(exc_tb)                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get                                
    return self._create_connection()                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection                     
    return _ConnectionRecord(self)                                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 678, in __init__                               
    self.__connect()                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 903, in __connect                              
    pool.logger.debug("Error on connect(): %s", e)                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                        
    raise exc_value.with_traceback(exc_tb)                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 898, in __connect                              
    self.dbapi_connection = connection = pool._invoke_creator(self)                                                          
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 645, in connect                            
    return dialect.connect(*cargs, **cparams)                                                                                
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 616, in connect                           
    return self.loaded_dbapi.connect(*cargs, **cparams)                                                                      
  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect                                   
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)                                                   
psycopg2.OperationalError: server didn't return client encoding                                                              

The above exception was the direct cause of the following exception:                                                         

Traceback (most recent call last):                                                                                           
  File "/usr/local/bin/migra", line 8, in <module>                                                                           
    sys.exit(do_command())                                                                                                   
  File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 121, in do_command                                    
    status = run(args)                                                                                                       
  File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 86, in run                                            
    m = Migration(                                                                                                           
  File "/usr/local/lib/python3.9/site-packages/migra/migra.py", line 39, in __init__                                         
    self.changes.i_target = get_inspector(                                                                                   
  File "/usr/local/lib/python3.9/site-packages/schemainspect/get.py", line 14, in get_inspector                              
    c = connection_from_s_or_c(x)                                                                                            
  File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 14, in connection_from_s_or_c                    
    return s_or_c.connection()                                                                                               
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2031, in connection                          
    return self._connection_for_bind(                                                                                        
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2047, in _connection_for_bind                
    return trans._connection_for_bind(engine, execution_options)                                                             
  File "<string>", line 2, in _connection_for_bind                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go                            
    ret_value = fn(self, *arg, **kw)                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1143, in _connection_for_bind                
    conn = bind.connect()                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3269, in connect                             
    return self._connection_cls(self)                                                                                        
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 147, in __init__                             
    Connection._handle_dbapi_exception_noconnection(                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2431, in _handle_dbapi_exception_noconnection
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e                                                            
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in __init__                             
    self._dbapi_connection = engine.raw_connection()                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection                      
    return self.pool.connect()                                                                                               
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect                                
    return _ConnectionFairy._checkout(self)                                                                                  
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout                             
    fairy = _ConnectionRecord.checkout(pool)                                                                                 
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 716, in checkout                               
    rec = pool._do_get()                                                                                                     
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 170, in _do_get                                
    self._dec_overflow()                                                                                                     
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                        
    raise exc_value.with_traceback(exc_tb)                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get                                
    return self._create_connection()                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection                     
    return _ConnectionRecord(self)                                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 678, in __init__                               
    self.__connect()                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 903, in __connect                              
    pool.logger.debug("Error on connect(): %s", e)                                                                           
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__                        
    raise exc_value.with_traceback(exc_tb)                                                                                   
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 898, in __connect                              
    self.dbapi_connection = connection = pool._invoke_creator(self)                                                          
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 645, in connect                            
    return dialect.connect(*cargs, **cparams)                                                                                
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 616, in connect                           
    return self.loaded_dbapi.connect(*cargs, **cparams)                                                                      
  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect                                   
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)                                                   
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server didn't return client encoding                            
(Background on this error at: https://sqlalche.me/e/20/e3q8) 

Using npx supabase@beta db pull --debug results in something like this

Pooler URL is not configured
Supabase CLI 1.142.0
2024/02/02 18:50:46 Sent Header: Host [api.moby.localhost]
2024/02/02 18:50:46 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/02/02 18:50:46 Send Done
2024/02/02 18:50:46 Recv First Byte
Connecting to remote database...
2024/02/02 18:50:48 Connect Start: tcp ...
2024/02/02 18:50:48 Connect Error: tcp ...
...: connect: connection refused
failed to connect to postgres: failed to connect to `host=....supabase.co user=postgres database=postgres`: dial error (dial tcp ... connect: connection refused)
sweatybridge commented 9 months ago

Pooler URL is not configured

I believe the second error can be resolved by running supabase link again. That will configure the pooler url locally for your project.

I will ping our internal team regarding the first error. It seems like the pooler response may not be fully compliant.

simicvm commented 9 months ago

thanks, that actually worked. I re-linked the project andnpx supabase@beta db pull worked fine.

honeybread commented 9 months ago

Yup, re-linking worked for me too. Thanks a lot!

emmyduruc commented 9 months ago

Any solution with this please image when i run supabase push and enter my password i get the above error. i reset db password and also link project yet if fails

ThingEngineer commented 9 months ago

when i run supabase push and enter my password i get the above error. i reset db password and also link project yet if fails

This should have been a new issue.

The Time Has Come... for IPv6

@emmyduruc Sorry to be the bearer of bad news but it looks like your network does not support IPv6. Check here: https://test-ipv6.com Or from the command line: curl -6 https://ifconfig.co/ip You should see an IPv6 address in your connection settings, not just an IPv4.

If not: Try another network, maybe share your phone's hotspot, a neighbor, or public access point.

You're gonna want to read this, you may need to opt into the IPv4 add on if you cannot resolve your local network IPv6 issue. https://supabase.com/docs/guides/database/connecting-to-postgres

From this issue: PGBouncer and IPv4 Deprecation #17817 ):

Do I need to make any changes if I am using the CLI?

If you are using a version before 1.136.3, please upgrade to a later version of the CLI and run supabase link. If you haven’t run supabase link since 1st January 2024, please run it again after upgrading. This will enable the CLI to communicate to the database from IPv4 only environments because the communication happens via Supavisor. This change is required if you are using from the CLI from an environment without IPv6 support, like Github actions or possibly from your home network.

However, this did not work for me. I had to break down and finally setup IPv6 on my home firewall. I was able to use my phone's hotspot to push db migrations in the interim.

To this date, running Supabase 1.142.2, I can relink on an IPv6 network, stop/start supabase local, but still cannot perform any action that attempts to connect to the remote db when on an IPv4 only network.

Greyvend commented 9 months ago

npx supabase@beta db push --db-url ... worked for me, even though test-ipv6.com showed "No IPv6 address detected".

ThingEngineer commented 9 months ago

npx supabase@beta db push --db-url ... worked for me, even though test-ipv6.com showed "No IPv6 address detected".

Thank's @Greyvend, I'll have to give that a go on another project. Definitely do not want to pull the beta on a production project.

Update: Went ahead and tried this out using a command with no side-effects and it does work for me as well. (disabled IPv6 for the test) Thank you Serge!

pnpx supabase@beta migration list --db-url postgres://[USER].[PROJ-REF]:[PASSWORD]@aws-0-us-west-1.pooler.supabase.com:[PORT]/[DB-NAME]

gorayaa66 commented 9 months ago

i tried with supabase@beta version 1.144.2 and still getting the same error "Network unreachable" while running the db diff command: npx supabase db diff --linked -f new_migrations

Things already tried

  1. npx supabase link
  2. npx supabase@beta migration list --db-url MY_DB_URL
  3. after that i'm getting database not healthy on npx supabase db diff --linked -f file: Connecting to remote database... Creating shadow database... Failed to remove container: bbdd6bece84049e71a42894119f5fb5a7de7fbf326a802df210c2b35a506edb3 Error response from daemon: No such container: bbdd6bece84049e71a42894119f5fb5a7de7fbf326a802df210c2b35a506edb3 database is not healthy Bug log error diffing schema: error running container: exit 1:
    Traceback (most recent call last):
    File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 9, in connection_from_s_or_c
    s_or_c.engine
    AttributeError: 'Session' object has no attribute 'engine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "db.skmwflowcvlfbmpqzcug.supabase.co" (2600:1f18:2e13:9d02:ace6:43f:445a:3a49), port 5432 failed: Network unreachable
Is the server running on that host and accepting TCP/IP connections?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/bin/migra", line 8, in
sys.exit(do_command())
File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 121, in do_command
status = run(args)
File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 86, in run
m = Migration(
File "/usr/local/lib/python3.9/site-packages/migra/migra.py", line 39, in init
self.changes.i_target = get_inspector(
File "/usr/local/lib/python3.9/site-packages/schemainspect/get.py", line 14, in get_inspector
c = connection_from_s_or_c(x)
File "/usr/local/lib/python3.9/site-packages/schemainspect/misc.py", line 14, in connection_from_s_or_c
return s_or_c.connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2031, in connection
return self._connection_for_bind(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2047, in _connection_for_bind
return trans._connection_for_bind(engine, execution_options)
File "", line 2, in _connection_for_bind
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
ret_value = fn(self, *arg, kw)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1143, in _connection_for_bind
conn = bind.connect()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3269, in connect
return self._connection_cls(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 147, in init
Connection._handle_dbapi_exception_noconnection(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2431, in _handle_dbapi_exception_noconnection
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in init
self._dbapi_connection = engine.raw_connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection
return self.pool.connect()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 716, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 170, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 678, in init
self.connect()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 903, in
connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 898, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 645, in connect
return dialect.connect(*cargs, *cparams)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 616, in connect
return self.loaded_dbapi.connect(
cargs,
cparams)
File "/usr/local/lib/python3.9/site-packages/psycopg2/init.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "db.skmwflowcvlfbmpqzcug.supabase.co" (2600:1f18:2e13:9d02:ace6:43f:445a:3a49), port 5432 failed: Network unreachable Is the server running on that host and accepting TCP/IP connections?

(Background on this error at: https://sqlalche.me/e/20/e3q8)

Emanuel-Manrique commented 3 months ago

This should be resolved in beta release v1.141.2

npx supabase@beta db pull

This solution works for:

failed to connect to host=localhost user=postgres database=postgres: failed to receive message (unexpected EOF) - Try rerunning the command with --debug to troubleshoot the error.