Unable to connect using psql

I’m trying to connect to my database using psql via the terminal. I’m new to sql.

psql 'postgres://ameydahikar:supersecretpassword@ep-long-glade-283413.us-east-2.aws.neon.tech/neondb?options=endpoint%3Dbr-muddy-sunset-282126&sslmode=require'

This results in psql: error: ERROR: password authentication failed for user 'ameydahikar'

Hi @ameydahikar
You should not have to specify this Server Name Indication (SNI) workaround option “?options=endpoint%3D” in your psql connection string. That’s a workaround option for drivers that do not support SNI.

For the branch you are trying to connect to, try grabbing a connection string for it from the Connect details widget on the Neon dashboard. Your psql command should look something like this:

psql postgres://daniel:password@ep-icy-sea-333477.us-east-2.aws.neon.tech/neondb?sslmode=require

when I do
psql 'postgres://ameydahikar:supersecretpassword@ep-long-glade-283413.us-east-2.aws.neon.tech/neondb?sslmode=require'

It results in
psql: error: ERROR: Endpoint ID is not specified. Either please upgrade the postgres client library (libpq) for SNI support or pass the endpoint ID (first part of the domain name) as a parameter: '?options=endpoint%3D<endpoint-id>'. See more at https://neon.tech/sni

OK. My mistake. I suspect you using an older version of Postgres? Pre v14? Support for SNI was added to libpq in PostgreSQL v14. If you try a newer version of Postgres (with psql), your connection should work.

Now, if you cannot upgrade Postgres:

I have not tried the SNI workarounds with psql, but the one you showed above is not defined correctly. Try this one:

psql ‘postgres://ameydahikar:supersecretpassword@ep-long-glade-283413.us-east-2.aws.neon.tech/neondb?options=endpoint%3Dep-long-glade-283413&sslmode=require’

That workaround and some others are described here:

Let me know how it goes.

1 Like

Thanks a lot, It worked!