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.

`The provided database string is invalid. Unable to parse URL. in database URL.` on invalid (?) connection string

See original GitHub issue

Something in this connection string seems to be weird, but the error message also does not make sense:

Connection string:

mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/e2e-tests?ssl=true

Error message:

D:\a\e2e-tests\e2e-tests\databases-windows\mongodb-azure-cosmosdb-emulator\script.ts:7:21

   4 
   5 // A `main` function so that we can use async/await
   6 async function main() {
→  7   await client.user.deleteMany(
  The provided database string is invalid. Unable to parse URL. in database URL. Please refer to the documentation in [prisma.io/docs/reference/database-reference/connection-urls](https://www.prisma.io/docs/reference/database-reference/connection-urls) for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.
    at cb (D:\a\e2e-tests\e2e-tests\databases-windows\mongodb-azure-cosmosdb-emulator\node_modules\@prisma\client\runtime\index.js:39809:17) {
  clientVersion: '3.10.0-dev.54',
  errorCode: undefined
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stevemucommented, Sep 16, 2022

for me, I had to define the “authentication database” to make it work, so:

this didn’t work (in .env):

DATABASE_URL="mongodb+srv://user:password@prod.abc.mongodb.net/?retryWrites=true&w=majority"

this works:

DATABASE_URL="mongodb+srv://user:password@prod.abc.mongodb.net/my-db?retryWrites=true&w=majority"

otherwise I would get Error: Error parsing connection string: Database must be defined in the connection string error

0reactions
grantjayycommented, Sep 16, 2022

@stevemu This worked for me - thank you for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

prisma can't connect to postgresql - Stack Overflow
Make sure that in your DATABASE_URL in the .env file, the special characters in your username and password are replaced with percent-encodings.
Read more >
Connection URLs (Reference) - Prisma
The connection URL is provided via the url field of a datasource block in your Prisma schema.
Read more >
Troubleshoot Connection Issues — MongoDB Atlas
To connect to Atlas, you must authenticate with a MongoDB database user. ... Incorrect Connection String Format ... 20, uri := "mongodb+srv://" +...
Read more >
34.1. Database Connection Control Functions - PostgreSQL
The following functions deal with making a connection to a PostgreSQL backend server. An application program can have several backend connections open at ......
Read more >
Setting the connection properties - JDBC Driver for SQL Server
(Version 6.0+) Use this property to connect to a database using an access token. accessToken can't be set using the connection URL.
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