What the message looks like
2026/10/29 09:14:02 [error] 1234#1234: *5678 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 203.0.113.5, server: example.com, request: "GET /app/ HTTP/2.0"Common causes
try_files $uri $uri/ /index.html;but/index.htmldoes not exist in theroot(build missing, wrong path).- The
rootor analiaswas changed and no longer points to the deployed site. - The
indexfile named in the config is not there. - A
locationorrewriterule sends the request back into itself. - A single-page app was deployed without its
index.html.
Check
- The effective rules for this site
nginx -T 2>/dev/null | grep -nE 'server_name|root |alias |try_files|index ' - Does the fallback file exist?
ls -l /var/www/app/index.html - The exact log lines
tail -n 20 /var/log/nginx/error.log - Is the configuration valid?
nginx -t
Fix
- Point
rootto the directory that really containsindex.html. - Make sure the build was deployed and
index.htmlis there and readable by nginx. - For a single-page app use
try_files $uri /index.html;and nothing that falls back to a path that again falls back. - With an
alias, check the trailing slashes and thattry_filesuses a path inside it. - Reload:
nginx -t && systemctl reload nginx.
Typical scenario
Your CI pipeline builds a React application and copies it to the server. The build step failed silently, so the target directory is empty. Every URL now answers 500, and the log says "rewrite or internal redirection cycle while internally redirecting to /index.html", although the configuration did not change. First check with ls -l on the server whether there is an index.html at the root path at all and when it was last written.
FAQ
Why 500 and not 404?
nginx stops after 10 internal redirects and reports a server error, because the loop is a configuration problem, not a missing page.
Can the same message come from a rewrite rule?
Yes. A rewrite without last, break or a clear exit condition can also loop. Check each rewrite in the matching location.
Why does nginx stop after exactly ten redirections?
The limit of ten internal redirects is fixed in the code and cannot be configured. It protects the server from endless loops. When it is reached, nginx answers 500 and writes the message to the error log; the visitor never sees the real reason.
How do I get a 404 instead of the loop?
End the fallback chain with =404, for example try_files $uri $uri/ =404;. nginx then returns a clean 404 for a missing file, and monitoring spots it differently from a 500. For single-page apps /index.html stays the last entry, but only if the file surely exists.
How do I prevent a moment without index.html during deployment?
Deploy into a new directory and switch a symlink afterwards, for example ln -sfn releases/42 current, with root pointing at it. The old release stays complete until the switch, and a failed build never reaches the live site.