question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When connecting to a non existing database server (or using invalid credentials), the Client error message does not include an Error Code

See original GitHub issue

Bug description

C:\Users\Jan\Documents\throwaway\timeoutTest>node script.js
PrismaClientInitializationError2 [PrismaClientInitializationError]: 
Invalid `prisma.user.create()` invocation:


  Can't reach database server at `lkjasdhfasdf.com`:`34234`

Please make sure your database server is running at `lkjasdhfasdf.com`:`34234`.
    at cb (C:\Users\Jan\Documents\throwaway\timeoutTest\node_modules\@prisma\client\runtime\index.js:35104:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async main (C:\Users\Jan\Documents\throwaway\timeoutTest\script.js:8:17) {
  clientVersion: '2.22.1',
  errorCode: undefined
}

How to reproduce

  1. New folder, npm init -y, npm install -D prisma, npx prisma init
  2. Add model to schema file
  3. npx prisma generate
  4. Copy over script from https://github.com/prisma/prisma-examples/blob/latest/javascript/script/script.js
  5. Set DATABASE_URL to non existant one like postgresql://johndoe:randompassword@lkjasdhfasdf.com:34234/mydb?schema=public
  6. Run node script.js
  7. Observe the error message above

Expected behavior

The error message should also include a documented (https://www.prisma.io/docs/reference/api-reference/error-reference) error code.

Prisma information

see above

Environment & setup

  • OS: Windows
  • Database: PostgreSQL, MySQL
  • Node.js version: v14.16.1
  • Prisma version:
C:\Users\Jan\Documents\throwaway\timeoutTest>npx prisma -v
Environment variables loaded from .env
prisma               : 2.22.1
@prisma/client       : 2.22.1
Current platform     : windows
Query Engine         : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\migration-engine-windows.exe)Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio               : 0.379.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
garrensmithcommented, Nov 18, 2021

This seems to be an error in the typescript client. If I run the master branch of the query-engine I get:

Nov 18 10:37:22.896  INFO query_engine:Encountered error during initialization:
{"is_panic":false,"message":"Authentication failed against database server at `localhost`, the provided database credentials for `postgres` are not valid.\n\nPlease make sure to provide valid database credentials for the database server at `localhost`.","meta":{"database_user":"postgres","database_host":"localhost"},"error_code":"P1000"}
make: *** [qe] Error 1

Notice the error code is defined there. But I can reproduce the above error with prisma 3.5.0 in nodejs.

Please make sure your database server is running at `lkjasdhfasdf.com`:`34234`.
    at cb (/Users/garren/dev/prisma/reports/test1/node_modules/@prisma/client/runtime/index.js:38681:17)
    at async main (/Users/garren/dev/prisma/reports/test1/index.js:8:17) {
  clientVersion: '3.5.0',
  errorCode: undefined
0reactions
jonathanheilmanncommented, Oct 29, 2021

We are facing the same problems. Without the Codes it’s nearly impossible to handle errors in different ways. Thus, we would appreciate a short-term solution/bugfix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Credentials are missing or not valid. inner except...
I am trying to make a connection to on premise database with windows credintials with no luck. It fails with this message. Credentials...
Read more >
Data Server Manager (DSM) shows "Invalid Credentials ... - IBM
Cause. DSM turns on the Invalid Credentials internal flag, when while connecting to the monitored database, DB2 returns -4214 error.
Read more >
How To Fix The "Error Establishing a Database Connection" in ...
1. Check Your Database Login Credentials. The first thing to do is check to ensure your database login credentials are correct. This is...
Read more >
LDAP Error Code 49 : Reset Machine Account Password of ...
This issue happens due to a mismatch in the machine account password stored in VMDIRD Database and the password used by services to...
Read more >
Error message reference - Prisma
When the first query is executed. Errors that can occur include: The provided credentials for the database are invalid; There is no database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found