508 Loop Detected
The server terminated an operation because it encountered an infinite loop.
Usually happens because:
- ☑ Circular symbolic directory references inside
- ☑ Internal routing loops between server
🔍 Quick Checklist:
Meaning
The HTTP 508 Loop Detected WebDAV server error status code indicates that the server terminated an operation because it encountered an infinite loop while processing a request with 'Depth: infinity'.
Root Causes
- Circular symbolic directory references inside WebDAV directories requested recursively.
- Internal routing loops between server configurations.
| Cause | Frequency |
|---|---|
| Circular symbolic directory references inside | ⭐⭐⭐⭐⭐ |
| Internal routing loops between server | ⭐⭐⭐⭐ |
Common Mistakes
- Configuring symbol links pointing back to parent directories on WebDAV file servers.
How to Fix
Framework-Specific Examples
Express router returning 508.
app.get('/traverse', (req, res) => {
res.status(508).send('Infinite loop detected in folder traversal.');
});Server Configuration Examples
Preventing circular loop proxying.
# Nginx tracks internal redirection limits returning 508 if exceededPrevention
- Guard directories traversal algorithms using visited path caches.
Frequently Asked Questions (FAQ)
Q: What is the difference between 508 Loop Detected and 208 Already Reported?
208 is a successful response (2xx) returned inside a Multi-Status body to indicate a duplicate link was skipped. 508 is an error response (5xx) indicating the server aborted the entire operation because it hit an infinite loop.
Q: What header is used to request infinite directory traversal?
WebDAV clients send the 'Depth: infinity' request header, which tells the server to recursively traverse all subfolders.
Q: Is 508 cacheable?
No. The 508 Loop Detected status code is never cached.
Q: How do servers detect loops?
By keeping a registry of filesystem node IDs (inodes) traversed during the request and checking if any ID is encountered twice.