NGINX 500 "Internal Redirect Cycle": Break the Loop

Symptom

Requests return 500 fast; error log shows "rewrite or internal redirection cycle".

Root cause

A location or rewrite sends the request back into itself.

Fix, in order

1. Find the loop in the loggrep "redirection cycle" /var/log/nginx/error.log
2. Typical culprit: try_files re-entering the same locationlocation / { try_files $uri $uri/ /index.html; } # if /index.html matches this location again, loop
3. Separate the fallthrough into an exact locationlocation = /index.html { root /app/dist; }

Prevent it coming back

One fallthrough rule per server; test with curl -H and error log open.

Deep-dive article

Full walkthrough: NGINX 500 "Internal Redirect Cycle": Break the Loop on the NinjaOps blog.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

Managed cloud hosting

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog