9 months ago
I am using express js app deployed in railway to connect to the mongo db internally. Connecting using the variable below works fine.
MONGO_URL=${{MongoDB.MONGO_URL}}But the connection is made to 'test' database. If I try to pass the dbname is the connection string I get authentication failed.
I checked the url format in the log and it is in the correct format.("uri":"mongodb:******@mongodb.railway.internal:27017/dbname").
If I just remove the dbname it connects fine. How do I connect to a specific database ?
2 Replies
9 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 Prisma: "Authentication failed against database server"
- 🧵 Data base error
- 🧵 "Authentication failed" error when connecting to MongoDB
- 🧵 Next.js + MongoDB Private URL on Railway - Connection Issues During Deployment
If you find the answer from one of these, please let us know by solving the thread!
Railway
Hey there! We've found the following might help you get unblocked faster: - [🧵 Prisma: "Authentication failed against database server"](https://station.railway.com/questions/prisma-authentication-failed-against-d-e2b17289) - [🧵 Data base error](https://station.railway.com/questions/data-base-error-15aba544) - [🧵 "Authentication failed" error when connecting to MongoDB](https://station.railway.com/questions/authentication-failed-error-when-conne-73594968) - [🧵 Next.js + MongoDB Private URL on Railway - Connection Issues During Deployment](https://station.railway.com/questions/next-js-mongo-db-private-url-on-railway-efbc4721) If you find the answer from one of these, please let us know by solving the thread!
9 months ago
yes this resolved the issue. DBName should be passed in options instead of the URL.
https://station.railway.com/questions/authentication-failed-error-when-conne-73594968
Thanks
Status changed to Solved asokaraja • 9 months ago