mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-04-25 09:25:55 +03:00
[GH-ISSUE #259] host.docker.internal is not resolved by nginx #227
Labels
No labels
awaiting feedback
bug
cannot reproduce
dns provider request
duplicate
enhancement
enhancement
enhancement
good first issue
help wanted
invalid
need more info
no certbot plugin available
product-support
pull-request
question
stale
troll
upstream issue
v2
v2
v2
v3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-proxy-manager-NginxProxyManager#227
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @devployment on GitHub (Dec 15, 2019).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/259
Checklist
jc21/nginx-proxy-manager:latestdocker image?✔️
✔️
Describe the bug
host.docker.internalis not resolved by nginxTo Reproduce
Steps to reproduce the behavior:
Run NPM
Run some web application on the Docker host (e.g. on port 5000)
Use

host.docker.internalas targetTry to access the proxied
host.docker.internal:5000Target page is not displayed and error is logged
Expected behavior
The NPM proxied domain, should show the page running under 127.0.0.1 on the Docker host
Workaround
If I ping
host.docker.internalon the runningappcontainer and use the resulting IP as target it worksOperating System
macOS
@devployment commented on GitHub (Dec 16, 2019):
Well, seems to be a general Docker issue
https://github.com/docker/for-mac/issues/2965
@Robokishan commented on GitHub (May 29, 2021):
I am still facing this issue. Any work around ?
But still it is not working in nginx any workaround ?
@devadattas commented on GitHub (Mar 21, 2022):
Same here!
@stealthdave commented on GitHub (May 12, 2022):
This looks to be an issue with
nginxrather than the Proxy Manager. Nginx itself does not seem to use/etc/hostsas a resolver:https://stackoverflow.com/questions/8305015/when-using-proxy-pass-can-etc-hosts-be-used-to-resolve-domain-names-instead-of/8559797#8559797
Perhaps a feature request to add
dnsmasqto the container that can be enabled with an environment variable, e.g.-e "ENABLE_DNSMASQ=true", to allow the use of--add-hostand/orextra_hostsin the docker setup as this is a very common use case to set up proxy servers for the docker host.@EDIflyer commented on GitHub (Jul 9, 2022):
Just came across this bug too (seems linked to #1225).
To confirm, when I run the following command:
docker run -it --name alpine4 --network nginx-proxy-manager_default --add-host host.docker.internal:host-gateway alpine ashI can happily ping 172.17.0.1 as well as host.docker.internal and can also wget to the service running on the host
However when setting up an NPM proxy pointed to
host.docker.internalit produces a 502 Bad Gateway openresty error. Changing the forward hostname/IP to172.17.0.1then works fine.(Just to confirm this is with the following text added to the nginx proxy manager Docker compose file too, so the host should have been mapped OK at a container level.)
@williamblair333 commented on GitHub (Jul 10, 2022):
Changing the forward hostname/IP to 172.17.0.1 then works fine.Would you give an example of that in a docker-compose file , or where would this change be made?@jbald18 commented on GitHub (Jul 11, 2022):
+1 ^^ @EDIflyer
@EDIflyer commented on GitHub (Jul 11, 2022):
Sorry thought I replied before - it was just in the npm proxy host...

@KeivanDjafarizad commented on GitHub (Sep 2, 2022):
Only workaround that I found, for development environment on the same machine, is to set network_mode: host, removing the ports and then forwarding to localhost. It's not the best but considering the fact that I'm using it to resolve names for local development, works for me
@Ran-Xing commented on GitHub (Sep 25, 2022):
@KeivanDjafarizad I also have network_mode: host ,
and curl and MySQL inside my container work fine
But nginx still doesn't resolve
How do you solve it now?
@hitesh-pathak commented on GitHub (Feb 11, 2024):
Is this actually resolved? Or is there any other issue to follow?
@seif2003 commented on GitHub (Jan 12, 2025):
In my case, the default Docker bridge network uses
10.0.0.1, which you can confirm by runningip addr show docker0. It works fine for me with 10.0.0.1.Also, you have to add
network_mode: hostin your Docker Compose file to ensure the container shares the host's network stack@JoshMcCullough commented on GitHub (Jan 24, 2025):
Doesn't the proper IP to use depend on your Docker network config, though?
@EDIflyer commented on GitHub (Jan 24, 2025):
Yes, but I've allocated a fixed IP to NPM so it doesn't keep changing.
@auxym commented on GitHub (Mar 12, 2025):
#1225 is open and is tracking the same issue, from what I understand