supabase: CLI: supabase link return password authentication failed for user "postgres" (SQLSTATE 28P01)

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When I try to use the cli to execute supabase link, I get the error message: password authentication failed for user “postgres” (SQLSTATE 28P01)

Command I tried to executed: supabase link --project-ref ********** supabase link --project-ref ********** --password ********

I copied the value listed under Reference ID in the screenshot below. projectsettings

Expected behavior

I expect to be able to successfully link my local to my remote project.

System information

  • OS: macOS Monterey 12.1
  • Version of supabase-cli: 1.68.6

Additional context

Potentially related: My project was paused for a few months. I restored it around 2-3 days ago.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Another alternative you could try is by setting the db password env var. For eg.

SUPABASE_DB_PASSWORD=<pass> supabase link --project-ref <ref>

May be there’s a special character that messed up bash. Let me know!

@sweatybridge Thanks, setting the password worked. I tried executing supabase link without setting the password to make sure that’s what the issue was, and yep it was. Appreciate the help!

SUPABASE_DB_PASSWORD=********** supabase link --project-ref **********
Finished supabase link.
supabase link --project-ref **********
Error: failed to connect to `host=db.**********.supabase.co user=postgres database=postgres`: failed SASL auth (FATAL: SASL authentication failed (SQLSTATE 08P01))

@RoyNyaga I got the same result as you. If you check the settings, in the Database section, you will notice that your IP has been baned for security reasons, that’s why the error has changed.

Hello guys, I have almost the same issue but mine comes up when pushing my migrations through supabase CLI using the command pnpm supabase db push.

I am able to link my local project with the one on cloud using the command supabase link --project-ref ********** but yet the pnpm supabase db push fails with the error message failed to connect to host=db.dszdioldqhzlbqutsjyp.supabase.co user=postgres database=postgres: dial error (dial tcp [64:ff9b::36c1:896b]:5432: connect: no route to host)

The server response descriptive error message says "Message":"password authentication failed for user \"postgres\"

I tried setting an environment variable as I have read in the above comments using the command (NB: I am on zsh terminal on MacOs)

export SUPABASE_DB_PASSWORD=********** supabase link --project-ref **********

This time around, I am not promoted to enter a password when I use the command pnpm supabase db push but I still have the same error.

Please any help on this will highly be appreciated. Thanks. @RobertB4 @sweatybridge

@saltcod I tried creating a new supabase account. I am still getting an error, though slightly different this time:

Error: failed to connect to `host=db.*****.supabase.co user=postgres database=postgres`: failed SASL auth (FATAL: SASL authentication failed (SQLSTATE 08P01))

When I run the command with --debug, I get:

2023/06/26 02:01:34 PG Recv: {"Type":"ErrorResponse","Severity":"FATAL","SeverityUnlocalized":"FATAL","Code":"28P01","Message":"password authentication failed for user \"postgres\"","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"auth.c","Line":326,"Routine":"auth_failed","UnknownFields":null}

I also tried using supabase link on a different computer. I get the same error message.

I am out of ideas. Different computer + new account with new project did not work.

Either this is a bug, or I am not using the right project ref? Is supabase link working for you or do you have any pointers what else I could try?

Hey @saltcod , I only had this one project, so I just tried to create a new one to test it. I get the same error:

supabase link --project-ref **********
Retrying... db.**********.supabase.co 5432
Error: failed to connect to `host=db.**********.supabase.co user=postgres database=postgres`: failed SASL auth (FATAL: password authentication failed for user "postgres" (SQLSTATE 28P01))

Another alternative you could try is by setting the db password env var. For eg.

SUPABASE_DB_PASSWORD=<pass> supabase link --project-ref <ref>

May be there’s a special character that messed up bash. Let me know!

I had to do this on Windows recently. The command is:

$env:SUPABASE_DB_PASSWORD="<pass>"; pnpx supabase link --project-ref <ref>

this worked for me as well. weird

Resetting the database password is not working for my case even there is no special character in the password. But explicitly declaring SUPABASE_DB_PASSWORD worked.

Another alternative you could try is by setting the db password env var. For eg.

SUPABASE_DB_PASSWORD=<pass> supabase link --project-ref <ref>

May be there’s a special character that messed up bash. Let me know!

Thank you. Reseting password for database helped.

Having the same issue when trying to do supabase db pull or supabase migration list. project links successfully.

tried setting password in the command line, still getting this:

failed to connect to host=db.<project id>.supabase.co user=postgres database=postgres: failed SASL auth (FATAL: password authentication failed for user "postgres" (SQLSTATE 28P01))

Anyone faced and resolved this?

@caroguerrerosilvera I think you are right cus my team added restrictions to some countries, I asked them and they confirmed it. Thanks so much @caroguerrerosilvera .

Hey @RobertB4 —sorry you’re having a terrible time here! I’ll ask the CLI team to have a look and see if they have any ideas!

Have you tried resetting your database password here? https://app.supabase.com/project/_/settings/database