Auxilor
Auxilor

Reputation: 109

Prisma - The provided database string is invalid. MongoDB connection string error

I'm being told I have an invalid connection string for my MongoDB data provider.

Specifically, I'm getting this: The provided database string is invalid. MongoDB connection string error: Missing delimiting slash between hosts and options in database URL.

My problem, however, is that my connection string does have a delimiting slash: it's this: mongodb://<user>:<pass>@cluster0.<server>.mongodb.net/?retryWrites=true&w=majority

What's going on? Is there anything I'm missing?

Upvotes: 8

Views: 12680

Answers (5)

John Edet
John Edet

Reputation: 11

Make sure your password do not contain any special character in your mongodb url string.

 DATABASE_URL="mongodb+srv://<user>:<pass>@<cluster_name>/<colection_name>? 
 retryWrites=true&w=majority"

i.e

 DATABASE_URL="mongodb+srv://sammy:devland@<cluster_name>/<colection_name>? 
 retryWrites=true&w=majority"

Upvotes: 1

Atul
Atul

Reputation: 2132

I was getting the same error resolved by checking the connection URI String by following

 DATABASE_URL="mongodb+srv://<user>:<pass>@<cluster_name>/<colection_name>? 
 retryWrites=true&w=majority"

Here collection name is important

Upvotes: 0

Bảo Long
Bảo Long

Reputation: 121

For someone who tried to connect mongodb in prisma, maybe you choose wrong connect , try to use type connect using VSCode

mongodb+srv://<admin>:<password>@cluster0.8hjts4c.mongodb.net/test 

it must have /test

Upvotes: 11

Cinamatic Universe
Cinamatic Universe

Reputation: 1

If you are using mongodb then just write database name as the path (replace <name> etc.)

mongodb://<user>:<pass>@cluster0.<server>.mongodb.net/<name>?retryWrites=true&w=majority

Upvotes: 0

Mikhael Abdallah
Mikhael Abdallah

Reputation: 488

It's missing database name after host: mongodb://<user>:<pass>@cluster0.<server>.mongodb.net/<mydb>?retryWrites=true&w=majority

Upvotes: 22

Related Questions