Node.js and MongoDB container connection in docker compose

Please share a best way to troubleshoot connection issue between a Node.js application container and a MongoDB container in a Docker Compose setup. The application fails to connect to the database when running ‘docker-compose up’. Any solution please?

We’re gonna need some more info please

Share your docker-compose.yml.

Use a Docker network to connect both, then use the service name to connect.

1 Like