MongoServerError: Authentication failed.

AnonymousTRIAL

a year ago

Hello,

I am trying to setup a connection to the Railway deployed MongoDB. I copied the MONGO_URL variable from the MongoDB deployment and set it up in the connection variable for my project. When I then try to deploy my project I get a "MongoServerError: Authentication failed." error in the log.

However, when I try the connection in MongoDB Compass, I can successfully connect.

Any thoughts on what I am doing wrong?

2 Replies

When I then try to deploy my project I get a "MongoServerError: Authentication failed." error in the log.

Where are you seeing this error?

Are you trying to access this database from within a Railway service, or externally?


AnonymousTRIAL

a year ago

I am seeing the error in the logs when I deploy on the railway service and when I try to connect via git bash on my local machine. So the answer to the question is both. Using the same connection string I can connect successfully in MongoDB Compass.