简体   繁体   中英

ECONNREFUSED : Communication between two docker containers in same docker network not working

Hi I have two Docker containers running which has node application in it, so that means I am trying to communicate between two node application running in seperate environments. Both of these containers are in same network called my-network .I tried entering inside the container using docker exec -it <container-name-or-id> /bin/bash and running ping to the other container. It seems like both containers are accessible to each other, but when I tried to connect to the other container inside the node application using request module with hostname as <other-container-name> .

Now I get the following error: Error: connect ECONNREFUSED xxxx:xxxx

Thanks in advance.

I have found the issue for my problem. Actually in my docker-compose.yml I have three services mentioned :

  1. node-app-1
  2. node-app-2
  3. mysql

Here container node-app-1 is trying to communicate to the container node-app- which must have a node express server running and listening to sepcific port xxxx . But application in node-app-2 was trying to ccreate connection with the mysql container for database access.Due to password specific reason it wasn't able to connect to connect to mysql and hence the express application in it was crashing and the server inside wasn't listening at that mentioned port. So when container node-app-1 tried to connect to other container, It threw an error , connection refused

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM