Docker container running on Linode server unable to connect to mongo atlas cluster

429 Views Asked by At

I'm trying to connect the node in Docker container which is running on my Linode server. I'm getting the following error.

MongoDB connection error. Please make sure MongoDB is running. MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/

If I run the same image in my local system everything works fine. DB connection is successfully establishing.

I added the docker IP address in the atlas cluster as whitelisted. I added my server IP address in the atlas cluster as whitelisted.

I used the below command to get the Ip of my docker container.

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <containerId>

Even after adding the IP of the container DB connection is throwing the error.

Since I'm new to docker Please let me know if I'm missing any steps in between or doing something wrong.

0

There are 0 best solutions below