[GH-ISSUE #641] Connection refused when forwarding to Docker container of same Docker network #543

Closed
opened 2026-02-26 06:33:19 +03:00 by kerem · 4 comments
Owner

Originally created by @kutoman on GitHub (Oct 8, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/641

What is troubling you?

connections by a reverse proxy setting to a docker container of the same docker network are refused.
I just can't figure out why the connections are refused. I feel like the fix is simple.

from the error log:

2020/10/08 18:03:02 [error] 269#269: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: ***.duckdns.org, request: "GET / HTTP/1.1", upstream: "http://172.19.0.3:80/", host: "***.duckdns.org"
2020/10/08 18:03:03 [error] 269#269: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: ***.duckdns.org, request: "GET / HTTP/2.0", upstream: "http://172.19.0.3:80/", host: "***.duckdns.org"

docker-compose.yml:

version: "3.7"

services: 
  jetty:
    container_name: jetty
    image: jetty:9
    ports:
      - '80'
    volumes:
      - './jetty/webapps:/var/lib/jetty/webapps'
  # for reverse proxy
  nginx-pm:
    container_name: nginx-pm
    image: jc21/nginx-proxy-manager:2
    restart: always
    ports:
    - 80:80 # Public HTTP Port
    - 443:443 # Public HTTPS Port:
    - 81:81 # Admin Web Port:
    volumes:
    - ./nginx-proxy-manager/config.json:/app/config/production.json
    - ./nginx-proxy-manager/data:/data
    - ./nginx-proxy-manager/letsencrypt:/etc/letsencrypt

proxy host setting:

grafik

when trying to access: (on both http and https)

grafik

Originally created by @kutoman on GitHub (Oct 8, 2020). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/641 **What is troubling you?** connections by a reverse proxy setting to a docker container of the same docker network are refused. I just can't figure out why the connections are refused. I feel like the fix is simple. **from the error log:** ``` 2020/10/08 18:03:02 [error] 269#269: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: ***.duckdns.org, request: "GET / HTTP/1.1", upstream: "http://172.19.0.3:80/", host: "***.duckdns.org" 2020/10/08 18:03:03 [error] 269#269: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: ***.duckdns.org, request: "GET / HTTP/2.0", upstream: "http://172.19.0.3:80/", host: "***.duckdns.org" ``` **docker-compose.yml:** ``` version: "3.7" services: jetty: container_name: jetty image: jetty:9 ports: - '80' volumes: - './jetty/webapps:/var/lib/jetty/webapps' # for reverse proxy nginx-pm: container_name: nginx-pm image: jc21/nginx-proxy-manager:2 restart: always ports: - 80:80 # Public HTTP Port - 443:443 # Public HTTPS Port: - 81:81 # Admin Web Port: volumes: - ./nginx-proxy-manager/config.json:/app/config/production.json - ./nginx-proxy-manager/data:/data - ./nginx-proxy-manager/letsencrypt:/etc/letsencrypt ``` **proxy host setting:** ![grafik](https://user-images.githubusercontent.com/5825645/95497864-48c32580-09a3-11eb-95d0-a7d34cd1d2c6.png) **when trying to access:** (on both http and https) ![grafik](https://user-images.githubusercontent.com/5825645/95498147-af484380-09a3-11eb-8612-83151e52a811.png)
kerem 2026-02-26 06:33:19 +03:00
Author
Owner

@zachthedev commented on GitHub (Oct 14, 2020):

@jc21 I am having this error too.
docker-compose.yml:

version: "3"
services:
  app:
    image: "jc21/nginx-proxy-manager:latest"
    ports:
      - "80:80"
      - "81:81"
      - "443:443"
    volumes:
      - ./config.json:/app/config/production.json
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
  db:
    image: "jc21/mariadb-aria:10.4"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "..."
      MYSQL_DATABASE: "...."
      MYSQL_USER: "..."
      MYSQL_PASSWORD: "..."
    volumes:
      - ./data/mysql:/var/lib/mysql

Error:
2020/10/14 04:17:51 [error] 10077#10077: *4025 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: sub.domain.com, request: "GET / HTTP/1.1", upstream: "https://xx.x.x.xxx:xxxx/", host: "sub.domain.com"

<!-- gh-comment-id:708148857 --> @zachthedev commented on GitHub (Oct 14, 2020): @jc21 I am having this error too. docker-compose.yml: ``` version: "3" services: app: image: "jc21/nginx-proxy-manager:latest" ports: - "80:80" - "81:81" - "443:443" volumes: - ./config.json:/app/config/production.json - ./data:/data - ./letsencrypt:/etc/letsencrypt db: image: "jc21/mariadb-aria:10.4" restart: always environment: MYSQL_ROOT_PASSWORD: "..." MYSQL_DATABASE: "...." MYSQL_USER: "..." MYSQL_PASSWORD: "..." volumes: - ./data/mysql:/var/lib/mysql ``` Error: `2020/10/14 04:17:51 [error] 10077#10077: *4025 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: sub.domain.com, request: "GET / HTTP/1.1", upstream: "https://xx.x.x.xxx:xxxx/", host: "sub.domain.com"`
Author
Owner

@kutoman commented on GitHub (Oct 14, 2020):

ok for my case.. the fix was really simple, as I initially expected... but it cost me a few days -.- I just assumed the wrong (default) port for my jetty container since jetty's default port is 8080 but I was using 80 instead. As a result, I had to adapt the proxy host setting accordingly as well.


  jetty:
    container_name: jetty
    image: jetty:9
    ports:
      - '8080' # <---
<!-- gh-comment-id:708693244 --> @kutoman commented on GitHub (Oct 14, 2020): ok for my case.. the fix was really simple, as I initially expected... but it cost me a few days -.- I just assumed the wrong (default) port for my jetty container since jetty's default port is 8080 but I was using 80 instead. As a result, I had to adapt the proxy host setting accordingly as well. ``` jetty: container_name: jetty image: jetty:9 ports: - '8080' # <--- ```
Author
Owner

@zachthedev commented on GitHub (Oct 15, 2020):

Not sure what fixed it for me, but I had just rebuilt the whole system a few times and then I got it.
Sorry for anyone coming from google to get help, but I don't have an answer.

<!-- gh-comment-id:709330683 --> @zachthedev commented on GitHub (Oct 15, 2020): Not sure what fixed it for me, but I had just rebuilt the whole system a few times and then I got it. Sorry for anyone coming from google to get help, but I don't have an answer.
Author
Owner

@adsanz commented on GitHub (Aug 18, 2021):

This issue is kinda old, the issue happens when your restart the container Nginx is forwarding to, they get a new IP and Nginx does not seem able to get the newer one, only fix I've seen is restarting nginx container.

<!-- gh-comment-id:900940882 --> @adsanz commented on GitHub (Aug 18, 2021): This issue is kinda old, the issue happens when your restart the container Nginx is forwarding to, they get a new IP and Nginx does not seem able to get the newer one, only fix I've seen is restarting nginx container.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#543
No description provided.