How to Fix Nginx Reverse Proxy Errors for Non-Existent ‘osiris’ Container & DNS Resolver


Quick answer: to fix Nginx reverse proxy errors that reference a non-existent ‘osiris’ container and an incorrect DNS resolver for Docker networking, capture the exact error, confirm whether ‘osiris’ is running and on the same Docker network as Nginx, check the resolver directive and upstream configuration, apply one change, reload Nginx, and verify the request.

This topic was selected from a public technical discussion signal and rewritten as an original troubleshooting guide. The goal is to explain the failure pattern, not to copy the original thread.

Applies To

Linux servers, Nginx, reverse proxies, PHP-FPM, Docker, Docker Compose, and production web applications.

Symptoms

  • Nginx returns a gateway error such as 502 Bad Gateway or 500 Internal Server Error for a request proxied to the ‘osiris’ service.
  • The Nginx error log contains a message such as host not found in upstream "osiris" or osiris could not be resolved.
  • The error appears after a container restart, container recreation, Docker network change, or Nginx reload, even though the user action itself is unchanged.
  • The browser, CLI, or dashboard shows a failure, but the message may not reveal the root cause.
  • The issue may affect only one service, endpoint, workflow, or environment.
  • Repeated retries may temporarily hide the problem without fixing the underlying cause.

Why Nginx Cannot Resolve the Container

When Nginx proxies to a Docker service by name, it must resolve that name to an IP address. A static upstream block resolves the name once when Nginx reads its configuration, so a container recreated with a new IP address can leave Nginx pointing at an address that no longer exists. When proxy_pass uses a variable, Nginx resolves the hostname for each request and needs a resolver directive; if that resolver is not Docker’s embedded DNS, Nginx cannot find the container even though docker ps shows it is running.

Docker’s embedded DNS server listens at 127.0.0.11 inside user-defined networks and resolves container names, service names, and network aliases for containers attached to that network. If the ‘osiris’ container is on a different network than the Nginx container, or the resolver directive points at a non-Docker DNS server, name resolution fails with a host-not-found style error.

Most Common Causes

  • The ‘osiris’ container is stopped, removed, unhealthy, or recreated under a different name than the one Nginx references.
  • The ‘osiris’ container and the Nginx container are attached to different Docker networks, so Nginx cannot see it by name.
  • A static upstream block resolved the container name at configuration load time, and the container has since been recreated with a new IP address.
  • The resolver directive is missing or points to a non-Docker DNS server (for example, an external or host resolver) instead of Docker’s embedded DNS at 127.0.0.11.
  • A configuration value changed, but the running process still uses an old file or environment.
  • Permissions, credentials, API tokens, or application passwords no longer match the runtime user.
  • A recent update changed a dependency, plugin, package, runtime, or protocol behavior.
  • The system is hitting a resource limit such as memory, workers, connections, disk space, or timeout.

Step-by-Step Fix

1. Capture the exact failure window

Record the error message, URL, user action, server name, and time window. This gives you a stable reference point when you compare Nginx logs, Docker events, and monitoring data.

date
hostname
journalctl --since "15 minutes ago" --no-pager
tail -n 100 /var/log/nginx/error.log
docker ps -a

2. Read the closest log first

Do not begin by restarting every service. A restart can hide the evidence. I start with the Nginx error log, because it usually names the upstream that failed: host not found in upstream "osiris" points to startup-time resolution, while osiris could not be resolved or no resolver defined to resolve osiris points to request-time resolution. Then check Docker events, application logs, and the workflow execution history.

3. Verify runtime state

Confirm that the ‘osiris’ container exists, is running, and is attached to the same Docker network as the Nginx container. Also confirm which port the service listens on and which configuration file the running Nginx process uses.

docker ps -a | grep osiris
docker inspect osiris --format '{{json .NetworkSettings.Networks}}'
docker network inspect your-network
docker exec nginx-container getent hosts osiris
systemctl status nginx
ss -lntp

4. Check configuration, permissions, and versions

Compare what the Nginx configuration says with what the runtime shows. Look for a static upstream osiris { ... } block, a proxy_pass http://osiris; line, and any resolver directive. For Docker, the resolver should point at the embedded DNS server (127.0.0.11) when the container name must be resolved for each request. Check file ownership, socket paths, credentials, environment variables, and versions, and identify exactly what changed if the issue started after an update.

nginx -t
grep -R "resolver\|proxy_pass\|upstream" /etc/nginx/
docker compose config
docker compose ps

5. Apply the smallest fix

Start with the failure pattern from the log. If the ‘osiris’ container is missing or on the wrong network, start it or attach it to the same network as the Nginx container, then test again. If a static upstream block points at a recreated container, reload Nginx so it re-resolves the name, or replace the static block with a variable plus Docker’s resolver:

resolver 127.0.0.11 valid=30s ipv6=off;
set $osiris_upstream http://osiris;
proxy_pass $osiris_upstream;

If the resolver directive already exists but points at a non-Docker DNS server, change it to 127.0.0.11. Then validate the configuration with nginx -t and reload Nginx (nginx -s reload or systemctl reload nginx) before testing the request.

6. Review resource limits

If the issue appears under load, inspect memory, CPU, disk space, connection limits, worker pools, queue length, and slow upstream dependencies. DNS queries can also time out when the resolver or network is saturated. Raising limits can help, but it should come after you understand why the limit was reached.

Verification

  • Run nginx -t and confirm the configuration is valid.
  • Run the original failing action again and confirm it no longer fails.
  • Check the relevant log after the fix and confirm the same error is no longer repeated.
  • Confirm name resolution from inside the Nginx container: docker exec nginx-container getent hosts osiris should return the container IP.
  • Verify service health with a command, HTTP request, workflow execution, or dashboard check.
  • If the issue was load-related, monitor memory, CPU, connections, and latency for at least one normal traffic window.

Production Notes

On a production system, avoid changing multiple settings at once. Save the original Nginx configuration, apply the smallest reasonable fix, and keep a rollback path. Changing the resolver directive affects every proxied hostname that relies on it, and changing container networks affects service discovery, so test in a controlled window whenever possible. If the fix involves credentials, plugin updates, firewall rules, database repair, or worker limits, apply the same caution.

FAQ

Why does Nginx say the ‘osiris’ container does not exist when docker ps shows it?

Usually one of three things is true: the name was resolved once at configuration load time and the container was recreated with a new IP, the two containers are on different Docker networks, or the resolver does not point at Docker’s embedded DNS server at 127.0.0.11. Verify the network and resolver first.

Should I restart the service first?

Only if the service is clearly stuck and you already saved the relevant logs. Restarting first may restore the system temporarily, but it can also remove the evidence needed to prevent the next incident.

What should I check if the problem comes back?

Look for a repeating trigger: container recreation or restarts, Docker network changes, Compose overrides, DNS changes, traffic spikes, scheduled jobs, plugin updates, dependency changes, expired credentials, disk growth, or a specific user workflow. Recurring failures usually mean the root cause is still active.

How do I know whether the fix worked?

Use more than one signal: the command returns successfully, nginx -t passes, the web request returns the expected status, the log stops showing the error, and the affected user workflow completes normally.

References