< HTTP/1.1 508 Loop Detected508 Loop Detected: Proxy and Redirect Loops
508 Loop Detected means the server found an infinite loop while processing a request. Learn the WebDAV origin, proxy loops, CDN-Loop and how to find the cycle.
- Cacheable
- Only with explicit freshness
- Retry?
- No: fix the loop
- Usually sent by
- WebDAV server
- Spec
- RFC 5842 §7.2
TL;DR: 508 means the server stopped a request because it was going in circles. Originally a WebDAV code for resource-binding cycles, it now mostly signals proxy or CDN loops, where a layer forwards a request back toward itself. Find the cycle with
ViaandCDN-Loopheaders and fix the upstream or DNS target.
What it means
RFC 5842 §7.2 defines 508 for WebDAV bindings: a PROPFIND or COPY with Depth: infinity that reaches a collection through a bind which includes an ancestor of itself would never finish, so the server stops with 508 and the whole operation fails.
Outside WebDAV, 508 is used by platforms and gateways that detect request loops. Vercel documents INFINITE_LOOP_DETECTED as an HTTP 508, raised for self-referencing requests, redirect cycles and recursive middleware or function calls. Standard web servers more often behave differently: nginx and Apache end internal redirect cycles with a plain 500 (“rewrite or internal redirection cycle”, LimitInternalRecursion), and a proxy that loops to itself usually produces 502 or 504 as connections pile up.
HTTP/1.1 508 Loop Detected
Content-Type: text/plain
Loop detected while processing /a/b
Typical causes
- Proxy pointing at itself.
proxy_pass http://example.com;inside the server forexample.com, where DNS for the upstream name resolves to the same machine or to the CDN that fronts it. Each pass adds anotherViaentry. - Two layers fetching from each other. The CDN’s origin is set to a hostname that is routed through the same CDN again.
- Rewrite or middleware loops in platform routers (a rewrite sends
/xto/yand a second rule sends/yback to/x). - WebDAV bind cycles where a collection contains a binding to its own ancestor, found by a
Depth: infinityoperation.
Find the cycle
curl -sv https://example.com/ -o /dev/null 2>&1 | grep -i -E '^< (via|cdn-loop|server|x-cache|cf-ray)'
< via: 1.1 edge-1.cdn-a.example, 1.1 edge-2.cdn-a.example, 1.1 edge-3.cdn-a.example
< cdn-loop: cdn-a; loops=3
Repeating Via entries with the same pseudonym show the same node is being revisited. RFC 8586 defines CDN-Loop, where each CDN appends its identifier so that a CDN receiving a request that already carries its own identifier too many times can refuse it. Then check where the proxy sends the request:
# From the proxy host: what does the upstream name resolve to?
dig +short upstream.example.com
getent hosts upstream.example.com
# Is it one of this host's own addresses?
ip -brief addr
In nginx, make sure the upstream is a different address than the listener, and keep proxy_set_header Host coherent with what the upstream expects, since a Host that routes back to the proxy is the classic loop.
Fix it
- Point the upstream at the origin’s own address or an internal hostname that does not go through the proxy.
- Remove one of the two layers’ fetch rules when two CDNs or proxies are chained.
- In platform rewrites, make the rules acyclic, and add conditions so a rewritten request does not match the rule again.
- For WebDAV, avoid
Depth: infinityon collections with bindings or break the cyclic binding.
Related
- 502 Bad Gateway
- 504 Gateway Timeout
- 500 Internal Server Error
- 301 Moved Permanently and 302 Found: where browser-side redirect loops start.
- Via
Frequently asked questions
What does 508 Loop Detected mean?
The server terminated the request because it detected an infinite loop. The code was defined for WebDAV bindings (RFC 5842), where a Depth: infinity operation could revisit the same resource through two paths, and is now also used by platforms for proxy or rewrite loops.
How is 508 different from ERR_TOO_MANY_REDIRECTS?
ERR_TOO_MANY_REDIRECTS is a browser giving up after about 20 redirects. 508 is a server or proxy stopping a loop on the server side, such as a proxy forwarding a request back to itself.
What causes a reverse proxy loop?
A proxy whose upstream resolves to itself (a DNS record or upstream pointing at the same host), or two CDN or proxy layers each configured to fetch from the other. Each hop adds Via or CDN-Loop entries, and the request never reaches an origin.
How do I find the loop?
Look at the Via and CDN-Loop headers, which list every hop, check each hop upstream setting and DNS resolution from the proxy host, and trace with curl -v using the Host header the proxy would send.
Sources
Related
507 Insufficient Storage: What the Error Means
507 means the server ran out of space to store what your request needs. Where it comes from, including WebDAV, uploads and quotas, and what to check.
511 Network Authentication Required: Captive Portals
511 is returned by a network gateway, such as hotel or airport Wi-Fi, that requires login before granting internet access. Learn how apps should handle it.
521 Web Server Is Down
Cloudflare-specific status code indicating the origin server refused the connection. Learn about this proxy error and how to troubleshoot it.
501 Not Implemented
The server doesn't support the functionality required to fulfill the request. Learn about unimplemented features.