HELP!... ConnectionRefusedError: [Errno:111] Connection Refused

when in Command Prompt and I try to run ‘docker-compose up’ Docker-compose starts up, but gets interrupted with the following message:

requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘127.0.0.1’, port=4040): Max retries exceeded with url: /api/tunnels (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7fe259c34be0>: Failed to establish a new connection: [Errno 111] Connection refused’,))

I don’t think it can be a Firewall issue because I replicated the same issue on my computer at home away from work, and it resulted in the same exact issue.
What could be the issue here?

Need to see what’s in your image start script or CMD

My Dockerfile goes as -->

FROM python:3.6-alpine

COPY . .

RUN pip install -r requirements.txt

EXPOSE 5004

CMD python cmxnotificationreceiver.py -u learning -p learning -l cmxlocationsandbox.cisco.com -i vy

and Docker-compose.yml -->

version: '2'

services:

  cmxnotificationreceiver:
    build: ./
    restart: on-failure
    container_name: cmxnotificationreceiver
    ports:
     - "0.0.0.0:5004:5004"
    volumes:
     - .:/cmxnotificationreceiver
    mem_limit: 100M

  ngrok:
    container_name: ngrok
    ports:
      - "0.0.0.0:4040:4040"
    image: wernight/ngrok
    links:
      - "cmxnotificationreceiver"
    environment:
      - NGROK_PORT=cmxnotificationreceiver:5004
    mem_limit: 100M

So clearly the error is coming from you python code … cmxnotificationreceiver.py

Make sure your process which will acquired the port 4040 is started inside you container before starting you python script.