[GH-ISSUE #2116] Can NPM ignore nginx: [emerg] host not found in upstream error? #1524

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

Originally created by @denppa on GitHub (Jun 18, 2022).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2116

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

Nginx Proxy Manager Version

NPM shows error at container up and won't start.

To Reproduce
Steps to reproduce the behavior:

  1. back up docker compose directory data with autorestic
  2. restore the exact same files with autorestic
  3. restart npm
  4. error log
    This is the errored line:
    proxy_pass       http://nextcloud:80/remote.php/dav;

Expected behavior

Just start right up, same container and host machine.

Screenshots
no

Operating System
ubuntu 20.04

Additional context
latest pulled docker version.

~/npm$ sudo docker compose pull
[+] Running 1/1
 ⠿ app Pulled
 "NPM_BUILD_VERSION=2.9.18",

compose file:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
      #- '81:81'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    container_name: npm

My current solution is to bomb the whole data folder and manually add back each domain, but that is a huge hassle, why doesn't the exact same data directory work?

EDIT:
Once I removed that conf file, the next conf files just continues to show the same error.

Originally created by @denppa on GitHub (Jun 18, 2022). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2116 <!-- Are you in the right place? - If you are looking for support on how to get your upstream server forwarding, please consider asking the community on Reddit. - If you are writing code changes to contribute and need to ask about the internals of the software, Gitter is the best place to ask. - If you think you found a bug with NPM (not Nginx, or your upstream server or MySql) then you are in the *right place.* --> **Checklist** - Have you pulled and found the error with `jc21/nginx-proxy-manager:latest` docker image? - Yes - Are you sure you're not using someone else's docker image? - Yes - Have you searched for similar issues (both open and closed)? - Yes **Describe the bug** <!-- A clear and concise description of what the bug is. --> **Nginx Proxy Manager Version** <!-- What version of Nginx Proxy Manager is reported on the login page? --> NPM shows error at container up and won't start. **To Reproduce** Steps to reproduce the behavior: 1. back up docker compose directory data with autorestic 2. restore the exact same files with autorestic 3. restart npm 4. [error log](https://pastebin.com/xEpJYnP0) This is the errored line: ``` proxy_pass http://nextcloud:80/remote.php/dav; ``` **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> Just start right up, same container and host machine. **Screenshots** no **Operating System** ubuntu 20.04 **Additional context** latest pulled docker version. ``` ~/npm$ sudo docker compose pull [+] Running 1/1 ⠿ app Pulled ``` ``` "NPM_BUILD_VERSION=2.9.18", ``` compose file: ``` version: '3' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' - '443:443' #- '81:81' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt container_name: npm ``` My current solution is to bomb the whole data folder and manually add back each domain, but that is a huge hassle, why doesn't the exact same data directory work? EDIT: Once I removed that conf file, the next conf files just continues to show the same error.
kerem 2026-02-26 07:31:25 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@denppa commented on GitHub (Jun 18, 2022):

Ok, so problem is that the proxy hosts have sub directories, and those are directing to hosts that are not up at that point yet. What would be a way for nginx to wait for other docker npm to just ignore the fact that they are not resolvable and just get up?

<!-- gh-comment-id:1159503641 --> @denppa commented on GitHub (Jun 18, 2022): Ok, so problem is that the proxy hosts have sub directories, and those are directing to hosts that are not up at that point yet. What would be a way for nginx to wait for other docker npm to just ignore the fact that they are not resolvable and just get up?
Author
Owner

@denppa commented on GitHub (Jun 18, 2022):

Solution: use the ip address of the container so npm won't have to resolve domain names.

<!-- gh-comment-id:1159519155 --> @denppa commented on GitHub (Jun 18, 2022): Solution: use the ip address of the container so npm won't have to resolve domain names.
Author
Owner

@eddywashere commented on GitHub (Aug 14, 2022):

Ok, so problem is that the proxy hosts have sub directories, and those are directing to hosts that are not up at that point yet. What would be a way for nginx to wait for other docker npm to just ignore the fact that they are not resolvable and just get up?

Also ran into this. I didn't connect what exactly sub directories meant here. For others running into this issue, if you have any Custom locations or sub directories that point to a host that is down (for me it was stopped docker container on shared internal npm network) this error will occur.

It's weird that npm/nginx has no issue starting up if a host is down without custom locations. I'm not sure what makes it a required dependency only as a custom location.

One workaround I did was to stop npm, edit the conf file to point to a container host that was running, and then restart.

Update: Originally I did this to add access controls on specific custom locations. Switching to $server vs hostname variable fixed this as it prevents DNS resolution at boot time. Might not work for everyone but I bet this is a common enough use case to avoid downtime.

image image
<!-- gh-comment-id:1214419357 --> @eddywashere commented on GitHub (Aug 14, 2022): > Ok, so problem is that the proxy hosts have sub directories, and those are directing to hosts that are not up at that point yet. What would be a way for nginx to wait for other docker npm to just ignore the fact that they are not resolvable and just get up? Also ran into this. I didn't connect what exactly sub directories meant here. For others running into this issue, if you have any `Custom locations` or sub directories that point to a host that is down (for me it was stopped docker container on shared internal npm network) this error will occur. It's weird that npm/nginx has no issue starting up if a host is down without custom locations. I'm not sure what makes it a required dependency only as a custom location. One workaround I did was to stop npm, edit the conf file to point to a container host that was running, and then restart. Update: Originally I did this to add access controls on specific custom locations. Switching to $server vs hostname variable fixed this as it prevents DNS resolution at boot time. Might not work for everyone but I bet this is a common enough use case to avoid downtime. <img width="479" alt="image" src="https://user-images.githubusercontent.com/399776/184550764-e8aeff5e-4d8f-44e0-8aa7-612ba088fe5d.png"> <img width="484" alt="image" src="https://user-images.githubusercontent.com/399776/184550775-269bed24-f0f9-4697-a32d-af04e9ed029a.png">
Author
Owner

@denppa commented on GitHub (Aug 14, 2022):

@eddywashere

Very clever solution, never thought I would ever had to use information in those lines of text.
Would you mind to show me how you defined the $server variable though? Is it in the text box under Advanced?

I am imagining something like this:

$server = nextcloud
<!-- gh-comment-id:1214444614 --> @denppa commented on GitHub (Aug 14, 2022): @eddywashere Very clever solution, never thought I would ever had to use information in those lines of text. Would you mind to show me how you defined the `$server` variable though? Is it in the text box under Advanced? I am imagining something like this: ``` $server = nextcloud ```
Author
Owner

@eddywashere commented on GitHub (Aug 15, 2022):

@Horuyuki those 3 variables including $server in the screenshot are tied to the settings of the proxy host (set in the Details tab). So reusing $server is only helpful if it happens to be the same hostname you need to reference in the custom location.

If you need to define another hostname variable to reference in custom location(s), you do need to set it in the Advanced tab when editing Proxy Host and add something like set $custom_server nextcloud2;

You have to do it that way due to the render ordering of the conf template here github.com/NginxProxyManager/nginx-proxy-manager@4db34f5894/backend/templates/proxy_host.conf (L25)

<!-- gh-comment-id:1214586176 --> @eddywashere commented on GitHub (Aug 15, 2022): @Horuyuki those 3 variables including $server in the screenshot are tied to the settings of the proxy host (set in the Details tab). So reusing $server is only helpful if it happens to be the same hostname you need to reference in the custom location. If you need to define another hostname variable to reference in custom location(s), you do need to set it in the Advanced tab when editing Proxy Host and add something like `set $custom_server nextcloud2;` You have to do it that way due to the render ordering of the conf template here https://github.com/NginxProxyManager/nginx-proxy-manager/blob/4db34f5894a2eb86e99683d52e9b7a859dd206a8/backend/templates/proxy_host.conf#L25
Author
Owner

@poiNt3D commented on GitHub (Sep 7, 2022):

Solution: use the ip address of the container so npm won't have to resolve domain names.

There is a problem with this solution. Docker uses dynamic ip addresses for containers and discourages using static ones.

<!-- gh-comment-id:1239727617 --> @poiNt3D commented on GitHub (Sep 7, 2022): > Solution: use the ip address of the container so npm won't have to resolve domain names. There is a problem with this solution. Docker uses dynamic ip addresses for containers and discourages using static ones.
Author
Owner

@kabadisha commented on GitHub (Mar 19, 2023):

I also had this problem. I've raised a PR which I believe fixes the issue:
https://github.com/NginxProxyManager/nginx-proxy-manager/pull/2672
If anyone on this thread can test my fix, that would be really helpful.

<!-- gh-comment-id:1475380710 --> @kabadisha commented on GitHub (Mar 19, 2023): I also had this problem. I've raised a PR which I believe fixes the issue: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/2672 If anyone on this thread can test my fix, that would be really helpful.
Author
Owner

@SimpleUserHA commented on GitHub (Jan 31, 2024):

@denppa Could this issues please be reopened or the #2672 being considered for review, since still lot's of people seem to have troubles with it.

<!-- gh-comment-id:1920112187 --> @SimpleUserHA commented on GitHub (Jan 31, 2024): @denppa Could this issues please be reopened or the #2672 being considered for review, since still lot's of people seem to have troubles with it.
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#1524
No description provided.