skip to Main Content

I have a development server where I am using Docker Compose to run all the related services. The docker-compose file looks roughly like:

services:
  webserver:
    - ports:
      - "${HOST_PORT}:${CONTAINER_PORT}"
  redis:
    - ports:
      - "${REDIS_PORT}:${REDIS_PORT}"
  apiserver:
    - ports:
      - "8383:8383"
  

(not a complete compose file, but I’ve only included what I believe are the relevant bits)

webserver spins up a BullMQ queue, which talks to redis. In one of the jobs that I have configured, I make a request to apiserver, via http://apiserver:8383/endpoint. If I ssh into the redis container and view the job that gets queue, I see that it has failed with the following: connect ECONNREFUSED 172.25.0.3:8383.

This works just fine when I run docker compose locally. Any idea why this might not be working?

Update:
Attempting a wget from within the web server instance:

wget http://apiserver:8383

results in:

wget http://apiserver:8383
--2022-12-24 23:58:28--  http://apiserver:8383/
Resolving apiserver (apiserver)... 172.26.0.4
Connecting to apiserver (apiserver)|172.26.0.4|:8383... failed: Connection refused.

2

Answers


  1. Chosen as BEST ANSWER

    Thank you for the responses. It turns out I wasn't paying close enough attention to the startup messages, and the apiserver was being Killed by Docker due to using too much memory. So the connection was refused because the server wasn't actually running.


  2. Docker-compose service names have to respect domain name standard format.
    Underscore "_" is not allowed in domain names.
    Raname your service to apiserver instead, you’ll be good

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search