The 508 Loop Detected HTTP status code indicates that the server terminated an operation because it detected an infinite loop while processing a request. This status code is most commonly associated with WebDAV environments but can also appear in misconfigured APIs or redirect chains.
HTTP status code 508 belongs to the server error category. It means the server recognized a loop during request processing and stopped execution to protect system resources.
// Express.js example demonstrating a redirect loop
app.get("/loop", (req, res) => {
res.redirect("/loop");
});
When a client accesses /loop, the server keeps redirecting the request to itself. Modern servers or proxies detect this loop and respond with a 508 Loop Detected error instead of continuing indefinitely.
Click the button below to simulate loop detection logic in JavaScript:
// Simulate loop detection using a counter
let count = 0;
while (true) {
count++;
if (count > 3) {
console.log("508 Loop Detected");
break;
}
}
Run Simulation: Watch how the "server" detects the recursion limit.