Connection refused message when i am trying to connect container

i am trying to download the cuckoo container from GitHub - blacktop/docker-cuckoo: Cuckoo Sandbox Dockerfile and when I try to connect the container with Sudo curl 172.18.0.6:80/cuckoo/status it says curl: (7) Failed to connect to 172.18.0.6 port 80: Connection refused. when I look at the port state with nmap it says closed maybe the problem is that but I cannot seem to change the port state from closed to open. I added screenshots and my YAML file in case it helps.

version: "2"

services:
  cuckoo:
    image: blacktop/cuckoo:2.0
    command: daemon
    ports:
      - "2042:2042"
    volumes:
      - ./cuckoo-tmp/:/tmp/cuckoo-tmp/
      - ./storage/:/cuckoo/storage/
    networks:
      - cuckoo
    env_file:
      - ./2.0/config-file.env

  web:
    image: blacktop/cuckoo:2.0
    ports:
      - "80:31337"
    links:
      - mongo
      - elasticsearch
      - postgres
    command: web
    volumes:
      - ./cuckoo-tmp/:/tmp/cuckoo-tmp/
      - ./storage/:/cuckoo/storage/
    networks:
      - cuckoo
    env_file:
      - ./2.0/config-file.env

  api:
    depends_on:
      - postgres
    image: blacktop/cuckoo:2.0
    ports:
      - "8000:1337"
    links:
      - postgres
    command: api
    volumes:
      - ./cuckoo-tmp/:/tmp/cuckoo-tmp/
      - ./storage/:/cuckoo/storage/
    networks:
      - cuckoo
    env_file:
      - ./2.0/config-file.env

 #  nginx:
 #    build: nginx/.
 #    depends_on:
 #      - mongo
 #    ports:
 #      - "80:80"
 #    links:
 #      - mongo
 #   networks:
 #      - cuckoo

  mongo:
    image: mongo
    ports:
      - 27017
    volumes:
      - mongo-data:/data/db
    networks:
      - cuckoo

  elasticsearch:
    image: blacktop/elasticsearch:5.6
    ports:
      - 9200
    volumes:
      - es-data:/usr/share/elasticsearch/data
    networks:
      - cuckoo
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    mem_limit: 1g

  postgres:
    image: postgres
    ports:
      - 5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: cuckoo
      PGDATA: /var/lib/postgresql/data/pgdata
      # POSTGRES_INITDB_ARGS: --data-checksums
    volumes:
      - postgres-data:/var/lib/postgresql/data/pgdata
    networks:
      - cuckoo

networks:
  cuckoo:
    driver: bridge

volumes:
  cuckoo-data:
  mongo-data:
  es-data:
  postgres-data:

Since I don’t have time to give you a detailed answer right now, just a quick note:

You used nmap to check a different IP address (172.18.0.7) than you try to access using curl (172.18.0.6). Was this intentional?

If this is not the problem, check your firewall. For example UFW or similar firewalls can restrict access to certain networks even from your host to one of the Docker networks if I remember correctly.

Can you describe the big picture for us, so we are able to understand the context?

Are you trying to access a containerized service by it’s container ip and container port or by the host ip and the published port?

If I’d guess, I would say it looks like your curl command uses {container ip}:{published host port} instead of {host ip}:{published host port}.

Indeed. The port numbers seems wrong too.

Note: I just looked at the dockerhub repo. The most recent images are 3 years old, so be prepared that the image itself will have plenty of vulnerabilites. Also the command: daemon was not mentionend anywhere… the github repo itself is set to read-only, which kind of looks like cuckoo is deprecated…

hi, thanks for the answer.I am trying to access the cuckoo service by its container IP and its port(that’s what I gathered from Github repo maybe I am wrong about that).

cuckoo is given to me as an intern project and I think there is a good chance that cuckoo has gone out of service as well. I am going to try to do a correct curl, thanks for the answer again.

thanks for the answer. ı corrected the port and adjust firewall but it still didn’t work

Please, listen to @meyay. :slight_smile: He noticed that you are using a wrong port. Based on your docker compose file “80” is the forwarded port from the host and not the port on which the service is listening in the container. So you need to use port 31337 with the container IP or use port 80 with your host IP.