Example HTTP Response
HTTP/1.1 508 Loop Detected- WebDAV infinite loop in resource binding
- Circular symbolic links
- Recursive operation detected
What does this mean?
Groundhog Day! The server caught itself going in circles. This request leads back to itself forever.
Technical Definition
The server detected an infinite loop while processing the request.
RFC Says
"The 508 (Loop Detected) status code indicates that the server terminated an operation because it encountered an infinite loop while processing a request with 'Depth: infinity'. This status indicates that the entire operation failed."
Plain English:
508 means 'I detected an infinite loop while processing your request.' This is from WebDAV and typically happens with recursive operations when there are circular references in the resource tree (like symbolic links that point to parent directories). The server stops processing to prevent hanging.
Common Misinterpretation
This is specific to WebDAV recursive operations with the Depth header. Application developers might use this concept for other graph traversal scenarios where circular references are detected, but it's not a standard use of 508 outside WebDAV.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(508).json({
error: 'Loop Detected',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(508, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Loop Detected',
message: 'Your error message here'
}));
}).listen(3000);