Docker Community Forums

Share and learn in the Docker community.

Difficulty getting containersized backend to talk to databases

I am trying to get my application running on my local machine using Docker Desktop for windows. I learned that applications are running on different vm’s which means you must connect them with an overlay network. I opened the ports 2377, 7946 (tcp) and 7946, 4789 (udp).

Now after running the commands at the very bottom my express app is still unable to talk with any of my redis db’s or my mongo db. Neo4j Im not sure but I suspect not.
Everything else excluding express still runs but when I run the express app all I get is:

 " `Error: Error connecting to db: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017`
`at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {`
`name: 'MongoNetworkError'`
`}]`"

docker run -itd --network=minipost-overlay-network -p 7474:7474 -p 7687:7687 neo4j
docker run -itd --network=minipost-overlay-network -p 6379:6379 redis
docker run -itd --network=minipost-overlay-network -p 6380:6380 redis
docker run -itd --network=minipost-overlay-network -p 6381:6381 redis
docker run -itd --network=minipost-overlay-network -p 6382:6382 redis
docker run -itd --network=minipost-overlay-network -p 6383:6383 redis
docker run -itd --network=minipost-overlay-network -p 6384:6384 redis
docker run -itd --network=minipost-overlay-network -p 27017:27017 mongo
docker run -itd --network=minipost-overlay-network -p 3001:3000 minipost-react
docker run -itd --network=minipost-overlay-network -p 5001:5000 minipost-express

Im wondering if there is an obvious mistep I am making somewhere?