[GH-ISSUE #2291] could not be resolved Host not found #1629

Closed
opened 2026-02-26 07:31:49 +03:00 by kerem · 7 comments
Owner

Originally created by @Ran-Xing on GitHub (Sep 25, 2022).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2291

docker-compose.yaml

version: '3'
services:
  app:
    image: 'chishin/nginx-proxy-manager-zh:latest'
    container_name: nginx-proxy-manager
    hostname: nginx-proxy-manager
    restart: always
    network_mode: "host"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    environment:
      DB_MYSQL_HOST: "mysql.docker.shared"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "nginxproxymanager"
      DB_MYSQL_PASSWORD: "nginxproxymanager"
      DB_MYSQL_NAME: "nginxproxymanager"

/etc/hosts

172.17.0.3      mysql.docker.shared     # AUDCH
172.19.0.3      gva-web.docker.shared   # AUDCH

CLI

nginx-proxy-manager

docker exec -it nginx-proxy-manager bash

[root@docker-nginx-proxy-manager:/app]# curl gva-web.docker.shared
<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">

...

[root@docker-nginx-proxy-manager:/app]# curl mysql.docker.shared:3306
Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: <FILE>" to save to a file.

vist

curl http://xxxxxxxxxxxxx.org
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty</center>
</body>
</html>

nginx-proxy-manager log

/data/logs/proxy-host-1_error.log 
2022/09/25 11:44:47 [error] 309#309: *1 gva-web.docker.shared could not be resolved (3: Host not found), client: xx.xx.xxx.xx, server: xxxxxxxxxxxxx.org, request: "GET / HTTP/1.1", host: "xxxxxxxxxxxxx.org"

nginx-proxy-manager web

image

Originally created by @Ran-Xing on GitHub (Sep 25, 2022). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2291 ## docker-compose.yaml ```docker-compose version: '3' services: app: image: 'chishin/nginx-proxy-manager-zh:latest' container_name: nginx-proxy-manager hostname: nginx-proxy-manager restart: always network_mode: "host" volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt environment: DB_MYSQL_HOST: "mysql.docker.shared" DB_MYSQL_PORT: 3306 DB_MYSQL_USER: "nginxproxymanager" DB_MYSQL_PASSWORD: "nginxproxymanager" DB_MYSQL_NAME: "nginxproxymanager" ``` ### /etc/hosts ```ini 172.17.0.3 mysql.docker.shared # AUDCH 172.19.0.3 gva-web.docker.shared # AUDCH ``` --- ### CLI nginx-proxy-manager ```bash docker exec -it nginx-proxy-manager bash [root@docker-nginx-proxy-manager:/app]# curl gva-web.docker.shared <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> ... [root@docker-nginx-proxy-manager:/app]# curl mysql.docker.shared:3306 Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your terminal anyway, or consider "--output Warning: <FILE>" to save to a file. ``` vist ```bash curl http://xxxxxxxxxxxxx.org <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>openresty</center> </body> </html> ``` nginx-proxy-manager log ```log /data/logs/proxy-host-1_error.log 2022/09/25 11:44:47 [error] 309#309: *1 gva-web.docker.shared could not be resolved (3: Host not found), client: xx.xx.xxx.xx, server: xxxxxxxxxxxxx.org, request: "GET / HTTP/1.1", host: "xxxxxxxxxxxxx.org" ``` nginx-proxy-manager web ![image](https://user-images.githubusercontent.com/73819467/192141839-de57f6ee-b6c6-4820-8a53-8397c81979fa.png)
kerem 2026-02-26 07:31:49 +03:00
Author
Owner

@the1ts commented on GitHub (Sep 25, 2022):

@Ran-Xing my guess is that the docker container will use /etc/hosts as part of its DNS resolution so your entries in /etc/hosts work, but nginx is using its inbuilt resolver which only looks at the resolver its told to ask, i.e. /etc/nginx/conf.d/include/resolvers.conf which is for me the docker inbuilt resolver 127.0.0.11.

<!-- gh-comment-id:1257268787 --> @the1ts commented on GitHub (Sep 25, 2022): @Ran-Xing my guess is that the docker container **will** use /etc/hosts as part of its DNS resolution so your entries in /etc/hosts work, but nginx is using its inbuilt resolver which only looks at the resolver its told to ask, i.e. /etc/nginx/conf.d/include/resolvers.conf which is for me the docker inbuilt resolver 127.0.0.11.
Author
Owner

@Ran-Xing commented on GitHub (Sep 25, 2022):

@the1ts Do you have any suggestions?

<!-- gh-comment-id:1257313062 --> @Ran-Xing commented on GitHub (Sep 25, 2022): @the1ts Do you have any suggestions?
Author
Owner

@the1ts commented on GitHub (Sep 26, 2022):

@Ran-Xing Either use IP:PORT on the host side which will not change without docker changes, or use the in built DNS of docker i.e docker container name resolves to its 172.*.*.* address already and the container and nginx already use that DNS. For example you will be able to get the IP for NPM by pinging nginx-proxy-manager, the name given in your compose.yml

<!-- gh-comment-id:1257624227 --> @the1ts commented on GitHub (Sep 26, 2022): @Ran-Xing Either use IP:PORT on the host side which will not change without docker changes, or use the in built DNS of docker i.e docker container name resolves to its `172.*.*.*` address already and the container and nginx already use that DNS. For example you will be able to get the IP for NPM by pinging nginx-proxy-manager, the name given in your compose.yml
Author
Owner

@Ran-Xing commented on GitHub (Sep 26, 2022):

I am using dnsmasq for parsing dns and I have modified the docker config file

[root@docker-nginx-proxy-manager:/app]# nslookup gva-web.docker.shared
Server:         172.17.0.1
Address:        172.17.0.1#53

Name:   gva-web.docker.shared
Address: 172.19.0.2

[root@docker-nginx-proxy-manager:/app]#

But nginx still cannot resolve

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty</center>
</body>
</html>

access.log

[26/Sep/2022:08:45:26 +0000] - 502 502 - GET http xxxxxx.org "/" [Client xx.xx.xx.xx] [Length 154] [Gzip -] [Sent-to gva-web.docker.shared] "curl/7.68.0" "-"

error.log

2022/09/26 08:46:11 [error] 324#324: *2034 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: xxxxxx.org, request: "GET / HTTP/1.1", upstream: "http://172.19.0.2:80/", host: "xxxxx.org"

But I found that it can be resolved now, but the IP address is wrong

➜  ~ /usr/bin/dig +short gva-web.docker.shared 172.17.0.1
172.19.0.3
➜  ~ docker exec -it nginx-proxy-manager /usr/bin/dig +short gva-web.docker.shared 172.17.0.1    
172.19.0.2
<!-- gh-comment-id:1257667828 --> @Ran-Xing commented on GitHub (Sep 26, 2022): I am using dnsmasq for parsing dns and I have modified the docker config file ```bash [root@docker-nginx-proxy-manager:/app]# nslookup gva-web.docker.shared Server: 172.17.0.1 Address: 172.17.0.1#53 Name: gva-web.docker.shared Address: 172.19.0.2 [root@docker-nginx-proxy-manager:/app]# ``` But nginx still cannot resolve ``` <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>openresty</center> </body> </html> ``` access.log ``` [26/Sep/2022:08:45:26 +0000] - 502 502 - GET http xxxxxx.org "/" [Client xx.xx.xx.xx] [Length 154] [Gzip -] [Sent-to gva-web.docker.shared] "curl/7.68.0" "-" ``` error.log ``` 2022/09/26 08:46:11 [error] 324#324: *2034 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: xxxxxx.org, request: "GET / HTTP/1.1", upstream: "http://172.19.0.2:80/", host: "xxxxx.org" ``` But I found that it can be resolved now, but the IP address is wrong ``` ➜ ~ /usr/bin/dig +short gva-web.docker.shared 172.17.0.1 172.19.0.3 ➜ ~ docker exec -it nginx-proxy-manager /usr/bin/dig +short gva-web.docker.shared 172.17.0.1 172.19.0.2 ```
Author
Owner

@the1ts commented on GitHub (Sep 27, 2022):

sorry, don't know what to say if docker DNS and what you say it should be are different.

<!-- gh-comment-id:1259439931 --> @the1ts commented on GitHub (Sep 27, 2022): sorry, don't know what to say if docker DNS and what you say it should be are different.
Author
Owner

@Ran-Xing commented on GitHub (Sep 27, 2022):

@the1ts https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2291#issuecomment-1257667828

The last paragraph.

<!-- gh-comment-id:1259444187 --> @Ran-Xing commented on GitHub (Sep 27, 2022): @the1ts https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2291#issuecomment-1257667828 The last paragraph.
Author
Owner

@the1ts commented on GitHub (Oct 1, 2022):

I haven't replied since if everything was setup correctly I cannot see how the Docker DNS is getting IPs wrong. Something else is happening that you haven't told us yet.

<!-- gh-comment-id:1264427526 --> @the1ts commented on GitHub (Oct 1, 2022): I haven't replied since if everything was setup correctly I cannot see how the Docker DNS is getting IPs wrong. Something else is happening that you haven't told us yet.
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#1629
No description provided.