508 Loop Detected
Infinite loops during directory tree traversal cause the 508 Loop Detected status code in WebDAV. In cPanel/CloudLinux hosting, the same code appears as 508 Resource Limit Is Reached when the account has used up its allowance of entry processes.
Usage specific to WebDAV
The 508 Loop Detected status code occurs
when the client submits a WebDAV
request for an entire directory and the result
creates a target within the same tree. This
produces an infinite request/response loop with
Depth: Infinity, and the server terminates the
entire operation.
Usage specific to cPanel / CloudLinux
The 508 Resource Limit Is Reached status code
is generated by shared hosting environments
running cPanel with CloudLinux when the
account's entry-process limit is reached. Each
Lightweight Virtual Environment (LVE) caps the
number of web server processes entering it at
once. Past the cap, mod_hostinglimits cannot
place the next process in the LVE and answers 508
instead. The other LVE limits surface differently:
CPU and I/O limits slow the site down, and memory
or process-count limits produce 500 or 503
when the script cannot start.
Example
A WebDAV client requests a recursive directory listing. The server detects a binding loop within the collection hierarchy and terminates the request.
Request
PROPFIND /shared/ HTTP/1.1
Host: www.example.re
Depth: infinity
Content-Type: application/xml
Response
HTTP/1.1 508 Loop Detected
Content-Type: text/html; charset=UTF-8
Content-Length: 174
<html>
<head>
<title>Loop Detected</title>
</head>
<body>
<p>The server detected an infinite loop
while processing the directory tree.</p>
</body>
</html>
How to fix
For WebDAV (508 Loop Detected):
A PROPFIND with Depth: infinity hit a circular
binding, where a collection contains a reference
back to a parent or to itself.
- Inspect the collection hierarchy for bind loops. A symbolic link or WebDAV binding pointing a child collection back to an ancestor creates the cycle. Remove or redirect the circular binding.
- Avoid
Depth: infinityrequests when possible. UseDepth: 1to list one level at a time and traverse the tree iteratively. Most WebDAV clients support this pattern. - In server-side code, add loop detection logic tracking visited collection URIs. Terminate traversal when a URI appears twice.
- Check the server log for the exact URI path where recursion was detected to pinpoint the misconfigured binding.
For cPanel / CloudLinux (508 Resource Limit Is Reached):
The hosting account reached its entry-process limit: too many requests were running at the same time.
- Log into cPanel and check the "Resource Usage" or "CPU and Concurrent Connection Usage" page to identify which limit was breached.
- Disable resource-heavy plugins or modules. WordPress sites with poorly optimized plugins frequently hit process and memory limits on shared hosting.
- Optimize database queries and enable page Caching to reduce per-request resource usage.
- Check for a traffic spike or DDoS attack driving resource consumption. Enable rate limiting or a CDN to absorb excess traffic before the requests reach the origin.
- Upgrade the hosting plan to a tier with higher CPU, memory, and process limits if the site has outgrown the current allocation.
Code references
.NET
HttpStatusCode.LoopDetected
Rust
http::StatusCode::LOOP_DETECTED
Rails
:loop_detected
Go
http.StatusLoopDetected
Symfony
Response::HTTP_LOOP_DETECTED
Python3.5+
http.HTTPStatus.LOOP_DETECTED
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_LOOP_DETECTED
Angular
@angular/common/http/HttpStatusCode.LoopDetected
See also
- RFC 5842: Binding Extensions to Web Distributed Authoring and Versioning (WebDAV)
- Google: HTTP status codes and network errors
- WebDAV
- 507 Insufficient Storage
- CloudLinux: LVE limits and error 508
- LiteSpeed: Troubleshooting CloudLinux 508 Resource Limit Reached
- HTTP status codes