HTTP 508 Loop Detected
Quick reference
| Code | 508 |
|---|---|
| Name | Loop Detected |
| Category | 5xx Server Error |
| Spec | RFC 5842 ยง7.2 |
| Context | WebDAV operations (PROPFIND Depth: infinity, COPY, MOVE) |
What 508 means
HTTP 508 Loop Detected is defined by RFC 5842, which extends WebDAV with binding support. A "binding" is a DAV concept where a single resource can appear at multiple collection (folder) paths simultaneously โ analogous to a hard link in a filesystem. Unlike symbolic links, DAV bindings create additional collection memberships rather than redirecting to another path.
When a client performs a PROPFIND with Depth: infinity, a COPY, or a MOVE operation, the server recursively traverses the collection tree. If the binding graph contains a cycle โ resource A is bound to collection B, which is also bound back to collection A โ the traversal would recurse infinitely. Rather than looping forever or crashing, the server detects the cycle and returns 508 Loop Detected to abort the operation.
508 is the complement to 208 Already Reported. Where 208 signals that a resource's properties have already been reported in this response body and will not be repeated (avoiding infinite output), 508 signals that the operation itself must be terminated because a loop was detected during traversal.
How circular bindings occur
Consider a WebDAV collection structure where:
Collection /projects/alpha/ โโโ /projects/alpha/assets/ (a binding to /shared/assets/) Collection /shared/assets/ โโโ /shared/assets/projects/ (a binding to /projects/) Collection /projects/ โโโ /projects/alpha/ (contains /projects/alpha/assets/...)
Following the chain: /projects/alpha/assets/ โ /shared/assets/projects/ โ /projects/alpha/ โ /projects/alpha/assets/ โ ... This creates a cycle. A PROPFIND Depth: infinity starting at /projects/ would traverse this loop endlessly without loop detection logic.
RFC 5842 requires WebDAV servers that implement bindings to track visited resource URIs during depth traversal and return 508 when a URI is encountered a second time.
The DAV:no-loop precondition
RFC 5842 also defines a precondition code DAV:no-loop used in error response bodies. When a BIND method call (creating a new binding) would introduce a cycle, the server rejects it with a 403 or 409 response containing a DAV:no-loop precondition in the XML body, preventing the cycle from being created in the first place:
BIND /projects/alpha/ HTTP/1.1 Host: dav.example.com Destination: /projects/alpha/assets/back-ref/ HTTP/1.1 403 Forbidden Content-Type: application/xml <?xml version="1.0" encoding="UTF-8"?> <D:error xmlns:D="DAV:"> <D:no-loop/> </D:error>
A 508 on a traversal operation (PROPFIND, COPY) means the server's precondition enforcement on prior BIND operations was absent or bypassed, and the cycle already exists in the binding graph.
508 vs 208
| Code | Meaning | When returned |
|---|---|---|
| 208 Already Reported | This resource was already listed in this 207 body | During successful multi-status traversal with repeated paths |
| 508 Loop Detected | Traversal loop found โ operation terminated | When a cycle makes the operation impossible to complete |
208 allows partial success โ the traversal continues but skips re-reporting known resources. 508 is an outright failure โ the entire operation is aborted.
Fixing 508 errors
The root cause is always a circular binding in the DAV namespace. The fix requires identifying and breaking the cycle.
Step 1 โ Identify the loop. Use a PROPFIND with Depth: 1 (not infinity) to safely enumerate immediate children of each collection without triggering the loop. Manually trace the binding chain to find the cycle.
Step 2 โ Remove the circular binding. Use the UNBIND method (RFC 5842 ยง4) to remove one leg of the cycle. Identify which binding is logically incorrect and delete it:
UNBIND /shared/assets/ HTTP/1.1 Host: dav.example.com <?xml version="1.0" encoding="UTF-8"?> <D:unbind xmlns:D="DAV:"> <D:segment>projects</D:segment> </D:unbind> HTTP/1.1 200 OK
Step 3 โ Enforce DAV:no-loop on future BINDs. If the WebDAV server implementation supports it, enable strict binding precondition checking to prevent future cycles. Most production WebDAV deployments (Apache mod_dav, SabreDAV) enforce this by default but it may be disabled in development configurations.
Frequently asked questions
Can 508 appear outside of WebDAV?
RFC 5842 defines 508 strictly for WebDAV binding traversal. However, the code is registered in the IANA registry without a WebDAV-only restriction, and some non-WebDAV systems (CDN routing engines, graph traversal APIs) have adopted 508 to signal infinite loop detection in their own traversal logic.
Is 508 the same as an infinite redirect loop?
No. Infinite redirect loops (where a URL redirects to itself or creates a cycle of 301/302 redirects) do not produce 508. Browsers and HTTP clients detect redirect loops client-side and show errors like "ERR_TOO_MANY_REDIRECTS". 508 is a server-side detection during a single request's processing.
Will a regular browser ever see a 508 response?
Browsers do not make WebDAV PROPFIND or BIND requests. A browser encountering a 508 would display it as a generic server error. 508 is relevant only to WebDAV clients (macOS Finder, Windows WebDAV, Cyberduck, SabreDAV clients) and applications that consume WebDAV APIs.
Does nginx or Apache return 508?
Apache with mod_dav returns 508 when a depth traversal detects a cycle in binding configurations. nginx does not implement WebDAV bindings (RFC 5842) โ the ngx_http_dav_module only supports basic WebDAV methods from RFC 4918 without binding support, so nginx would not generate 508.
Related guides
HTTP 208 ยท HTTP 207 ยท HTTP 500 ยท HTTP 506 ยท HTTP 507
Server Errors Hub ยท All Guides ยท Home