Hello everyone,

I tried to setup docker-compose with two containers: a site 1 (Nuxt.js app) and the Nginx reverse-proxy to reach the site at site1.mydomain.com.

When I access site1.mydomain.com, I get the following error:

proxy_1  | 2018/07/13 09:50:12 [error] 5#5: *9 connect() failed (111: Connection refused) while connecting to upstream, client:, server: site1.mydomain.com, request: "GET / HTTP/1.1", upstream: "", host: "site1.mydomain.com"

Here is the docker-compose.yml configuration:

version: "3"
    image: registry.gitlab.com/XXX/YYY:latest  # (Nuxt.js app)
      - webnet
      - "3000"
      - "3000:3000"
    command: "npm run start"
    image: nginx:latest
      - ./nginx.template:/etc/nginx/conf.d/nginx.template
      - "80:80"
      - webnet
      - web
    command: /bin/bash -c "envsubst '$$NGINX_HOST $$NGINX_PORT' < /etc/nginx/conf.d/nginx.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

Here is the nginx.template configuration :

server {
    listen 80;
    server_name site1.mydomain.com;
    location / {
        proxy_pass http://web:3000;
    proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Here is the output of docker-compose up:

Creating preprod-site_web_1 ... done
Creating preprod-site_nginx_1 ... done
Attaching to preprod-site_web_1, preprod-site_nginx_1
web_1    |
web_1    | > app_test@1.0.0 start /
web_1    | > nuxt start
web_1    |
web_1    | [10:03:21] [NUXT:AXIOS] baseURL: http://localhost:3000/
web_1    | [10:03:21] [NUXT:AXIOS] browserBaseURL: http://localhost:3000/
web_1    |
web_1    |  OPEN  http://localhost:3000
web_1    |

Here is the /etc/hosts XXX XXX  # I have hidden the hostname localhost site1.mydomain.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I tried a lot of other configurations but I always ended up with this error.

What is wrong ? Is there a restriction on the port 3000 somehow ?

I checked that my app was running in the container called web by checking the output of curl localhost:3000 inside the container.

Thank you in advance,

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

2 answers


What I could suggest is checking if your containers are part of the new network:

docker network inspect webnet

Then test the connection:

docker exec -ti nginx ping web


For me I had a network error issue. My server didnt have the proper host of

'localhost' or better yet '' 

and so even though I could plug the domain name and the port into my browser and even curl and get some data back, internally my client side node app didnt seem to be able to read the correct web address when I said the host to



netstat -plnt

to see what ports are actually being listened to and try using ‘’ for all hosts

Submit an Answer