cli icon indicating copy to clipboard operation
cli copied to clipboard

Failed to connect to postgres

Open shelbye-mfp opened this issue 3 months ago • 14 comments

Describe the bug Error connecting to postgres after trying to link supabase CLI to another project. Unlinking another.

The same issue as here - https://github.com/supabase/cli/issues/3960 (I tried what was suggested there, still error.)

To Reproduce Steps to reproduce the behavior:

  1. Run supabase CLI and run supabase link
  2. See Error
failed to connect to postgres: failed to connect to `host=aws-1-ap-southeast-2.pooler.supabase.com user=cli_login_postgres.PROJECT_ID database=postgres`: AfterConnect error (ERROR: permission denied to set role "postgres" (SQLSTATE 42501)

System information Rerun the failing command with --create-ticket flag.

  • Ticket ID: [e.g. 21b825bc3818499882ea5bc86313999a]
  • Version of OS: [Ubuntu 24.04.3 LTS]
  • Version of CLI: [^2.51.0]
  • Version of Docker: [v28.4.0]
  • Versions of services: [output from supabase services command]

shelbye-mfp avatar Oct 17 '25 11:10 shelbye-mfp

I have this same error, it was marked resolved in another thread about the same issue. but it persists for me.

MitchSchwartz avatar Oct 23 '25 02:10 MitchSchwartz

same here, both with the latest and the beta version of the cli

alessandrolattao avatar Oct 28 '25 17:10 alessandrolattao

same error here, happened when i updated the cli to the newest version

thewengchan avatar Nov 01 '25 18:11 thewengchan

This error is happening for me too. Using version 2.54.11

royally-handmade avatar Nov 03 '25 06:11 royally-handmade

We have released a fix for this server side. Could you guys try the same command again?

sweatybridge avatar Nov 03 '25 11:11 sweatybridge

I am still receiving an error, but now it says: Failed SASL auth (invalid SCRAM server-final-message received from server)

heikopaiko avatar Nov 07 '25 18:11 heikopaiko

Was getting this error, after spending alot of time come to know that, my ip was banned in Database setting, IDK how but it is, unban it and working now

lancer-code avatar Nov 08 '25 14:11 lancer-code

Was getting this error, after spending alot of time come to know that, my ip was banned in Database setting, IDK how but it is, unban it and working now

Dude, you just saved my weekend vibing session. Thank you!

andresg747 avatar Nov 09 '25 20:11 andresg747

Was getting this error, after spending alot of time come to know that, my ip was banned in Database setting, IDK how but it is, unban it and working now

Yeap, this is the problem. My IP has been marked "abusive" for no reason

dadanisme avatar Nov 12 '25 01:11 dadanisme

I started encountering this issue in my CI pipeline since yesterday, I can't link my project- receiving this error: failed to connect to postgres: failed to connect to host=db.[MASKED].supabase.co user=cli_login_postgres database=postgres: dial error

I checked and I couldn't see any ip ban in my project settings. Any other ideas on how to fix it?

Thanks in advance!

michael-elyon avatar Nov 25 '25 12:11 michael-elyon

I started encountering this issue in my CI pipeline since yesterday, I can't link my project- receiving this error: failed to connect to postgres: failed to connect to host=db.[MASKED].supabase.co user=cli_login_postgres database=postgres: dial error

I checked and I couldn't see any ip ban in my project settings. Any other ideas on how to fix it?

Thanks in advance!

Same here.

This is the output in our GitLab CI/CD pipeline, that was working fine til 5 days ago

npx supabase link --project-ref $SUPABASE_PROJECT_ID
Connecting to remote database...
failed to connect to postgres: failed to connect to `host=db.[SUPABASE_PROJECT_ID].supabase.co user=postgres database=postgres`: dial error (dial tcp [2a05:d019:fa8:a402:48c3:a1b:e46d:e1c8]:5432: connect: network is unreachable)
Try rerunning the command with --debug to troubleshoot the error.

francescocretti avatar Nov 25 '25 17:11 francescocretti

I started encountering this issue in my CI pipeline since yesterday, I can't link my project- receiving this error: failed to connect to postgres: failed to connect to host=db.[MASKED].supabase.co user=cli_login_postgres database=postgres: dial error

I checked and I couldn't see any ip ban in my project settings. Any other ideas on how to fix it?

Thanks in advance!

Same here.

This is the output in our GitLab CI/CD pipeline, that was working fine til 5 days ago

npx supabase link --project-ref $SUPABASE_PROJECT_ID
Connecting to remote database...
failed to connect to postgres: failed to connect to `host=db.[SUPABASE_PROJECT_ID].supabase.co user=postgres database=postgres`: dial error (dial tcp [2a05:d019:fa8:a402:48c3:a1b:e46d:e1c8]:5432: connect: network is unreachable)
Try rerunning the command with --debug to troubleshoot the error.

Restart or Recreate the project

lancer-code avatar Nov 25 '25 17:11 lancer-code

I think the issue is related to IPv4 support drop https://supabase.com/docs/guides/troubleshooting/supabase--your-network-ipv4-and-ipv6-compatibility-cHe3BP

francescocretti avatar Nov 25 '25 17:11 francescocretti

@michael-elyon I can confirm than in my case the issue was caused by supabase link, which attempts to connect over IPv6. Since the GitLab CI/CD runner doesn’t support IPv6, the command failed.

I resolved the problem by removing supabase link from the pipeline and replacing it with commands that accept the --db-url parameter and the supavisor connection string instead.

For example:

supabase db push --db-url postgresql://postgres.[YOUR_PROJECT_ID]:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgres

francescocretti avatar Nov 25 '25 19:11 francescocretti