[GH-ISSUE #1021] Restarting docker containers may change its IP address and cause '502 bad gateway' #856

Open
opened 2026-02-26 06:34:42 +03:00 by kerem · 4 comments
Owner

Originally created by @GeorgeWells on GitHub (Apr 15, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1021

I've put together a docker-compose file with 2 services (php:8.0-fpm-alpine and nginx:stable-alpine) within the same network as nginx-proxy-manager and have a proxy host record pointing to the name of the nginx service. I have found that sometimes when I run docker-compose down and then docker-compose up -d I may get a 502 error. This does disappear after a while which I believe matches up with my findings.

I have found that when running docker network inspect NETWORKNAME between each time I run the above commands I have noticed that the 502 error happens when the IP address of the nginx container changes and then the error goes away once DNS has re-cached its IP address from the service name. I've also noticed that I can disable then re-enable the proxy record to resolve the 502 error which I believe triggers an nginx reload in the proxy manager.

I'm not sure if the IP address should always be the same therefore a potential bug/issue with docker or something can be done in reverse-proxy-manager to ensure that the IP address that is mapped to the service name is updated when a 502 happens. Maybe something in cron to re-cache the IP addresses for all the proxy records every 3-5 minutes would help to diminish the issue.

I'm using Docker 20.10.6 on a Raspberry Pi 4 (Raspberry Pi OS - Buster 32bit).

Originally created by @GeorgeWells on GitHub (Apr 15, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1021 I've put together a docker-compose file with 2 services (php:8.0-fpm-alpine and nginx:stable-alpine) within the same network as nginx-proxy-manager and have a proxy host record pointing to the name of the nginx service. I have found that sometimes when I run `docker-compose down` and then `docker-compose up -d` I may get a 502 error. This does disappear after a while which I believe matches up with my findings. I have found that when running `docker network inspect NETWORKNAME` between each time I run the above commands I have noticed that the 502 error happens when the IP address of the nginx container changes and then the error goes away once DNS has re-cached its IP address from the service name. I've also noticed that I can disable then re-enable the proxy record to resolve the 502 error which I believe triggers an nginx reload in the proxy manager. I'm not sure if the IP address should always be the same therefore a potential bug/issue with docker or something can be done in reverse-proxy-manager to ensure that the IP address that is mapped to the service name is updated when a 502 happens. Maybe something in cron to re-cache the IP addresses for all the proxy records every 3-5 minutes would help to diminish the issue. I'm using Docker 20.10.6 on a Raspberry Pi 4 (Raspberry Pi OS - Buster 32bit).
Author
Owner

@github-actions[bot] commented on GitHub (Mar 13, 2024):

Issue is now considered stale. If you want to keep it open, please comment 👍

<!-- gh-comment-id:1993072685 --> @github-actions[bot] commented on GitHub (Mar 13, 2024): Issue is now considered stale. If you want to keep it open, please comment :+1:
Author
Owner

@Automatik commented on GitHub (Jan 28, 2025):

I'm having the same issue!

<!-- gh-comment-id:2619103891 --> @Automatik commented on GitHub (Jan 28, 2025): I'm having the same issue!
Author
Owner

@github-actions[bot] commented on GitHub (Aug 21, 2025):

Issue is now considered stale. If you want to keep it open, please comment 👍

<!-- gh-comment-id:3208733331 --> @github-actions[bot] commented on GitHub (Aug 21, 2025): Issue is now considered stale. If you want to keep it open, please comment :+1:
Author
Owner

@urbenlegend commented on GitHub (Feb 9, 2026):

This happens to me as well in my Podman containers. For me, I find that it only happens to custom locations, not the main host itself. For example, I have a Nextcloud instance that has custom locations for the whiteboard and notify_push.

Domain Name: nextcloud-domain.com
Scheme: http, Forward Hostname / IP: nextcloud, Port: 80

Custom Location 1: /whiteboard/
Scheme: http, Forward Hostname / IP: nextcloud-whiteboard-server/, Port: 3002

Custom Location 2: /push/
Scheme: http, Forward Hostname / IP: nextcloud-notify-push/, Port: 7867

If I reboot my Nextcloud docker-compose, it takes a few seconds for the main domain to come up but it does eventually come up. /whiteboard/ and /push/ however do not.

<!-- gh-comment-id:3873471115 --> @urbenlegend commented on GitHub (Feb 9, 2026): This happens to me as well in my Podman containers. For me, I find that it only happens to custom locations, not the main host itself. For example, I have a Nextcloud instance that has custom locations for the whiteboard and notify_push. **Domain Name:** nextcloud-domain.com **Scheme:** http, **Forward Hostname / IP:** nextcloud, **Port:** 80 **Custom Location 1:** /whiteboard/ **Scheme:** http, **Forward Hostname / IP:** nextcloud-whiteboard-server/, **Port:** 3002 **Custom Location 2**: /push/ **Scheme:** http, **Forward Hostname / IP:** nextcloud-notify-push/, **Port:** 7867 If I reboot my Nextcloud docker-compose, it takes a few seconds for the main domain to come up but it does eventually come up. /whiteboard/ and /push/ however do not.
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#856
No description provided.