0

I have a multi tenant node application. I'm encountering an issue when trying to connect to local PostgreSQL database using node-postgres. Whenever the program attempt to execute a function (internally executing a SQL query), I receive the following error message:

error: password authentication failed for user "abc"

Since this is a multi-tenant application in the database it has multiple schemas and also multiple roles, it has the schema called abc and also the user abc as well.

I've double-checked the username and password and even updated it multiple times. However, I'm still getting the above error. Also, in PgAdmin if I execute the same query using the same user abc it is executing the query fine.

I'm unsure why the authentication is failing despite providing the correct credentials. Could someone please advise on potential troubleshooting steps or solutions to resolve this issue? Also, how can I turn on the debug logs for this node-postgres?

Thank you in advance for your assistance!

4
  • Since it's a multi-tenant app, what creds do you use when creating the client? If the client is created with abc, running the query with def won't satisfy the auth. Could you provide some more details about how you create clients and the flow to run the schema-user-dependent queries? It's going to be an 'aah gotcha' type of answer! Commented Apr 9, 2024 at 21:15
  • Look in the server's log file to find the error message. It will generally contain additional information (which is not sent to the unauthenticated and presumably hostile client) about why the authentication failed. Commented Apr 10, 2024 at 15:28
  • @sandiejat I cloned the DEV database and restored to my local. When the application is connected to DEV it is working totally fine. The credentials are same as postgres. And even for every role I changed the password multiple times. So I added a new record to the pg_hba.conf file by changing the method to trust (default was scram-sha-256) and it worked (I know it is not recommended), but still I don't understand why it didn't work, is this an issue with may be authentication mechanism not supported or database migration version issue? I still cannot figure it out, can I get some hints? Commented Apr 14, 2024 at 21:27
  • @jjanes Actually the logs didn't help much, I checked the Postgres logs also. Commented Apr 14, 2024 at 21:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.