Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI project link SASL authentication failed #1760

Open
BahaMagi opened this issue Dec 18, 2023 · 53 comments · Fixed by #2425
Open

CLI project link SASL authentication failed #1760

BahaMagi opened this issue Dec 18, 2023 · 53 comments · Fixed by #2425
Labels
bug Something isn't working
Milestone

Comments

@BahaMagi
Copy link

Describe the bug
Similar issue as described here: supabase/supabase#15184
Created a new issue here since I suspect this to be a CLI issue.

Created a new project and tried to link the CLI to the project with

npx supabase link 

selecting the project manually to make sure the ref is correct. Tried both: providing the password in an env variable and providing it manually when trying to link. From another PC in the same office it works, from this one I get

failed to connect to postgres: failed to connect to `host=db.<out project ID>.supabase.co user=postgres database=postgres`: failed SASL auth (FATAL: SASL authentication failed (SQLSTATE 08P01))

And my IP is listed as blocked in the Supabase Database settings.

Resetting password did not help.

Connecting to the DB directly via for example PGAdmin works as well, so connection link and PW are definitely correct.

Desktop (please complete the following information):

  • OS: Win10
  • Version of CLI 1.126.0
  • Version of supabase-js: 2.39
  • Version of Node.js: 18.19.0
@sweatybridge
Copy link
Contributor

Could you send a bug report with the following command

npx supabase@beta link --project-ref <ref> --create-ticket

After that, share the crash ID here so we can retrieve the diagnostics information.

@BahaMagi
Copy link
Author

Thank you for looking into this!
Ran the above command and got

a7c1098a188f4f24a5ab2b776cd28574

as crash ID

@BahaMagi
Copy link
Author

BahaMagi commented Jan 4, 2024

Any news on this? Not being able to use the CLI is somewhat limiting....

@medclans
Copy link

Same steps as above and below is the crash ID
13addb48fe85407d9654266ccbc6dd7a

@chanmathew
Copy link

chanmathew commented Mar 6, 2024

I'm having similar issue - 0d53919556f041ea831728258b4be8e0

This is the error i get:

failed to connect to postgres: failed to connect to `host=aws-0-us-east-1.pooler.supabase.com user=postgres.<REDACTED> database=postgres`: failed SASL auth (invalid SCRAM server-final-message received from server)

@JTCorrin
Copy link

Same issue:

9a5bea6ec9a842b8ace7d5e0620265fb

@chanmathew
Copy link

I'm having similar issue - 0d53919556f041ea831728258b4be8e0

This is the error i get:

failed to connect to postgres: failed to connect to `host=aws-0-us-east-1.pooler.supabase.com user=postgres.<REDACTED> database=postgres`: failed SASL auth (invalid SCRAM server-final-message received from server)

Update on this - turns out updating my DB password that was generated by supabase (a shorter one) seems to have fixed it. Perhaps the one I generated previously didn't work due to password length? Hope this helps others running into this issue.

@JTCorrin
Copy link

The way I'm getting around it now is to link and deploy via github actions. The password I am using to link locally is correct (but failing)

@henry2man
Copy link

henry2man commented Mar 15, 2024

@BahaMagi Please check your Supabase CLI version. I was on 1.113.3 and updated to recent 1.148.6 ... and the issue was gone. NOTE: I reset the password before updating the CLI.

Maybe this is related with IPv4 deprecation: https://github.com/orgs/supabase/discussions/17817

@kathleen-saz
Copy link

Same issue: fd6fce781a134bc7ab3fa6da0c414401

@zolotokrylin
Copy link

same issue here :(

@sweatybridge
Copy link
Contributor

Could you try the latest version?

npx supabase@latest link

It's probably due to an implementation difference between transaction mode of pgbouncer and supavisor which we recently rolled out on port 6543.

@lelandmiller
Copy link

Hey! I was having the same issue even on latest. @chanmathew's tip to use the password generated by supabase worked for me as well. I wonder if it was related to special characters in my password, # in particular.

@sweatybridge
Copy link
Contributor

I tested on macOS with passwords containing special char # and up to 50 characters in length but still unable to reproduce. Will try win10 later this week

@jventura7
Copy link

getting same issue
crash id: d635a8a3279f4815940d0f920744c9c2

@mdotmoment11
Copy link

same issue. tried the linking and upgraded to latest supabase (1.154.1):
crash id: 1b6bae554170469282c03ca74fbabe1e

@mdotmoment11
Copy link

same issue. tried the linking and upgraded to latest supabase (1.154.1): crash id: 1b6bae554170469282c03ca74fbabe1e

Just went to UI and changed the pw (recommended by supabase). works now

@sweatybridge
Copy link
Contributor

Closing as it seems resolvable by pw reset.

@mdotmoment11 Do you remember if your previous password had any special characters in it?

@chanmathew
Copy link

Just to add, i do notice that in the CLI, it doesn't seem to automatically pickup your password even if logged in, and I had to explicitly export my password to my shell and then run supabase link.

@mdotmoment11
Copy link

mdotmoment11 commented Apr 18, 2024 via email

@p-shubh
Copy link

p-shubh commented May 15, 2024

Hey every one i also have the same issue dii you got any solution

[error] failed to initialize database, got error failed to connect to host=aws-0-us-east-1.pooler.supabase.com user=postgres.axwqqoifubxkipmilrmm database=postgres: failed SASL auth (invalid SCRAM server-final-message received from server)

@p-shubh
Copy link

p-shubh commented May 15, 2024

I got resolved this by reset the db password of supabase

@DylanGoodfellow
Copy link

DylanGoodfellow commented May 30, 2024

failed to connect to postgres: failed to connect to 'host=aws-0-eu-west-2.pooler.supabase.com user=postgres.<user> database=postgres': failed SASL auth (invalid SCRAM server-final-messsage received from server)
Even the password reset didnt work for me. Setting the SUPABASE_DB_PASSWORD env var also did not help. However when i changed way i was pasting in to the console (right click to ctrl+v) it worked. Pasting both ways to the terminal produce the same exact characters, not sure whats going on here.

@p-shubh
Copy link

p-shubh commented May 30, 2024

Might be the project password is the db password

@rohankm
Copy link

rohankm commented Jun 1, 2024

facing same issue

@pblue3
Copy link

pblue3 commented Jun 2, 2024

Same here... Password are correctly spelled and inside env var.

@eamondunne
Copy link

Same issue here

@MohammedFaragallah
Copy link

supabase.exe link didn't work

supabase.exe link --project-ref worked

🤷‍♂️

@reckziegelwilliam
Copy link

Same issue

@rohankm
Copy link

rohankm commented Jun 11, 2024

facing same issue

@sweatybridge sweatybridge reopened this Jun 11, 2024
@sweatybridge sweatybridge added the bug Something isn't working label Jun 11, 2024
@sweatybridge
Copy link
Contributor

However when i changed way i was pasting in to the console (right click to ctrl+v) it worked. Pasting both ways to the terminal produce the same exact characters, not sure whats going on here.

I can reproduce this exact behaviour on windows powershell. Ctrl+v works but not typing into the prompt.

@Bobetti
Copy link

Bobetti commented Jul 1, 2024

same error. Password change using supabase generate button does not help.
Crash ID: dcf17de12fbe4b06b3063aed622a3255
Error occurs if I use VS Code PowerShell terminal
When I switched to Git Bash terminal - everything went smooth, no error.
Don't know why PowerShell gives errors.

@PleahMaCaka
Copy link

PleahMaCaka commented Jul 1, 2024

I've tried this on both Windows and Linux, but I'm having trouble. Is there a temporary solution to this?

@sweatybridge
Copy link
Contributor

Is there a temporary solution to this?

The temporary workaround is to set SUPABASE_ACCESS_TOKEN environment variable. For eg.

SUPABASE_ACCESS_TOKEN=<your-token> supabase link --project-ref <ref>

@gludington
Copy link

gludington commented Jul 2, 2024

None of the above workarounds worked for me, but, if you are on OSX, check your default shell and parameters. For me, while I was using bash, by default I had different properties set in the default shell. When I spawned a new shell without the default properties and THEN ran supabase link in that new shell, it worked.

@taily-khucnaykhongquantrong

None of the above worked for me.
My crash ID: b8074d9e0002406dafc595e06a46e497.

@Battjmo
Copy link

Battjmo commented Jul 18, 2024

Turn my terminal off and turned it on again and it works 🤷

@nechita
Copy link

nechita commented Jul 24, 2024

none of the workarounds worked for me. Crash id: 8ce31208b251403199da79c74cafd726

@L-Sypniewski
Copy link

I had the same issue, it started working after changing a password so that it doesn't contain dollar sign characters

@timmy-newtron
Copy link

I am receving the same issue.

I have the strong feeling htat this has to do with special characters in the password. This happened to me before and I built a db psuh script that URL-encodes the password before issuing the command:

const urlEncodedPassword = encodeURIComponent(process.env.SUPABASE_DB_PASSWORD);

const connectionString = `postgres://${process.env.SUPABASE_DB_USER}:${urlEncodedPassword}@${process.env.SUPABASE_DB_HOST}:${process.env.SUPABASE_DB_PORT}/${process.env.SUPABASE_DB_NAME}`;

const command = `supabase db push --db-url ${connectionString}`;

@bigshaq1230
Copy link

Hello i tried typing the password manually instead of copy paste and it worked

@oleva
Copy link

oleva commented Sep 5, 2024

Hi,

For me @sweatybridge got it:

However when i changed way i was pasting in to the console (right click to ctrl+v) it worked. Pasting both ways to the terminal produce the same exact characters, not sure whats going on here.

I can reproduce this exact behaviour on windows powershell. Ctrl+v works but not typing into the prompt.

In case somebody missed this. So does not work in Docker terminal, or Visual code terminal etc.

BUT on command prompt I could run without errors. Running supabase commands with NPX

@dixhuit
Copy link

dixhuit commented Oct 12, 2024

Same issue here. Crash ID: a1c94bf14bc84c83bd08215cf5e836b2

  • No special chars in PW.
  • Linux OS.
  • Pasted PW with Ctrl + V.
  • Tried resetting PW and used PW suggested by Supabase.
  • Tried running commands in both WebStorm terminal as well as Konsole terminal.

@stevonadlax
Copy link

Set the password manually in supabase Reset Password window. Don't use any special characters, except '!'.
Don't copy-paste it in the VSCode terminal. Type it manually, from your memory, not from copied text box on supabase. put it in the .env SUPABASE_DB_PASSWORD= variable. Don't paste it, type it manually. Works for me.

@JeremieLitzler
Copy link

Hey! I was having the same issue even on latest. @chanmathew's tip to use the password generated by supabase worked for me as well. I wonder if it was related to special characters in my password, # in particular.

Yes, I think that having a # does cause problem. I have a couple in mine (generated password) and I had issues.

Also, for windows user, I recommend using the CLI through scoop (https://scoop.sh/#/apps?q=supabase) rather than the npm package. Somehow, after installing it in my project, I couldn't make it work nor did I find a way to reset it all.

@f0rodo
Copy link

f0rodo commented Dec 11, 2024

yeah special characters in the pwd is messing this up. Super annoying that it has been a year and this is still not fixed.

@xidsyed
Copy link

xidsyed commented Dec 13, 2024

none of these is working for me. whats going on Supabase 😭😭😭. i've never seen this much superstition in a github issue thread

@xidsyed
Copy link

xidsyed commented Dec 13, 2024

I use windows. Nothing worked in powershell. Opened GIt Bash terminal and pasted it in. worked instantly 🤷‍♂️

@JeremieLitzler
Copy link

After all, I made it work: I uninstalled the npm package and created a .bashrc file with the commands I use:

# To use the aliases below, make sure to run `source .bashrc`
#
# Then use these aliases:
alias sp-init='supabase init'
alias sp-login='supabase login'
alias sp-link-env='source .env && echo "linking to $SUPABASE_PROJECT_ID ... using password=$SUPABASE_PROJECT_PASSWORD" && supabase link --project-ref $SUPABASE_PROJECT_ID'
alias sp-gen-types='source .env && supabase gen types --lang=typescript --project-id "$SUPABASE_PROJECT_ID" --schema public > src/types/database.types.ts'
alias sp-db-mnew='supabase migration new $1'
alias sp-db-mup='supabase migration up --linked'
alias sp-db-reset='supabase db reset --linked'
alias sp-db-seed='node --env-file=.env database/sedding.js'
alias sp-db-rs='sp-db-reset && node --env-file=.env database/sedding.js'

I run it in Git bash.

@ampeixoto
Copy link

In my case, what made it work was to past it using CTRL+SHIFT+V.

  • Windows
  • Powershell terminal in VS Code

@JayBit33
Copy link

I was having the same issue as everyone and I'm guessing some of you are doing the same thing I did. I didn't actually click the reset password button after generating a new password because I thought it was to reset the password again. For some reason the UI just made me feel like it was updated without clicking the button. Make sure you click reset password. Hope this helps someone.

@OndrejDrapalik
Copy link

This seems to be a bug inside the CLI tool. I had the exact same issue when I was casually pasting "cmd+v" to the terminal AND HITTING ENTER.

Once I tried to paste with "cmd + SHIFT + v" cli automatically triggered the login and all worked well.

I see the intention to to space user hitting the enter, but in this case seem to back fire in a terrible/hard to debug issue we all are facing.

@zxdream64230
Copy link

Same error here. No problem with one of ny supabase project but get the error for my second project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.