Hi everyone. I’m struggling to get Prisma setup wi...
# mongodb
m
Hi everyone. I’m struggling to get Prisma setup with Mongodb running on Atlas. The issue seems to be using replica sets in my connection URL. If I have a URL like this:
Copy code
<mongodb://user:password@shard-1.mongodb.net:27017/database?ssl=true&replicaSet=shard-1&authSource=admin&retryWrites=true>
Everything works fine. But if I use multiple shards, like this:
Copy code
<mongodb://user:password@shard-1.mongodb.net:27017>,<http://shard-2.mongodb.net:27017,shard-3.mongodb.net:27017/database?ssl=true&replicaSet=shard-0&authSource=admin&retryWrites=true|shard-2.mongodb.net:27017,shard-3.mongodb.net:27017/database?ssl=true&replicaSet=shard-0&authSource=admin&retryWrites=true>
I get the following error:
Copy code
Error: The provided database string is invalid. Unable to parse URL. in database URL. Please refer to the documentation in <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.
I can make the error go away on startup if I percentage encode the host section of the URL (which shouldn’t be necessary!), but then it blows up when I try and run a query. Using Prisma Client 3.9.1. Does anyone have any suggestions? Thanks 🙂
j
Thanks for the feedback! Could you open an issue about this? I think it should be investigated by us
m
Will do, thanks
https://github.com/prisma/prisma/issues/11684 for your viewing pleasure 🙂
💚 1
m
I think it could be related to this issue. https://github.com/prisma/prisma/issues/10934 Try to drop the ports in the connection string.
j
Thanks for the link looks related indeed!