Meteor DDP call between containers on same host

This Meteor App server code tries to use the method of another Meteor worker. both the app and the worker are in a separate docker containers on the same server EC2. The worker is running on port 9000.
When the App fires a method appCallingWorker, I expected to see the worker container logs out the string ‘worker called from App’ but all docker logs containerID gives is many lines looking like this:
stream error Network error: ws://localhost:9000/websocket: connect ECONNREFUSED

How can I use the methods of the worker from the App? thx

  • docker add “requires at least one argument” error
  • How to start many docker-compose services with different client configs?
  • Merge two docker images
  • sharing docker.sock or docker in docker (dind)
  • How to use Docker (or Linux Containers) for Network Emulation?
  • Cannot connect to MySQL within running docker container
  • //App/server/main.js
    let workerConn = DDP.connect('http://localhost:9000');
     'appCallingWorker': () => {'workerMethod');
      'workerMethod': function () {
        console.log('worker called from App');

    The EC2 is a Container Instance in AWS ECS. and the containerDefinitions.portMapings.containerPort and hostPort are both set to 9000.
    edit 2
    iptables -L -n on the docker host shows the ip of the container listening on 9000, I replaced localhost in the code with said ip and now it works. But Said ip can change if host reboot or container restarts… another problem to find a solution for.

  • Docker Base Image Size configured in daemon.json
  • Vagrant mount error after installing Docker
  • Synced Folder Error with Docker Provider on Vagrant
  • Deploy nginx official image, the volumn mount incorrectly
  • How to select volume mountpoint in docker-compose.yml?
  • Ionic docker Failed to open the browser
  • One Solution collect form web for “Meteor DDP call between containers on same host”

    i had this same problem trying to communicate between docker containers. you’re going to have to use the external ip:port address of the server your containers are on.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.