508

Loop Detected

Overview

508 Loop Detected means the server detected an infinite loop while processing the request. In WebDAV it is returned when a deep traversal (Depth: infinity) over bindings (similar to symbolic links) that reference each other would repeat endlessly.

Rather than traverse the resources forever, the server detects the loop and aborts with 508 — a safeguard against unbounded resource consumption.

When it happens

Request / Response example

Request
PROPFIND /a/ HTTP/1.1
Host: dav.example.com
Depth: infinity
(a and b are bindings that reference each other)
Response
HTTP/1.1 508 Loop Detected
Content-Type: application/xml

<D:error xmlns:D="DAV:"><D:no-external-entities/></D:error>

In code

// Track visited nodes so a cyclic binding structure aborts as 508
const seen = new Set();
function walk(node, res) {
  if (seen.has(node.id)) { res.status(508); throw new Error('loop'); }
  seen.add(node.id);
  node.children.forEach(c => walk(c, res));
}

Common causes

How to fix

Notes

Related status codes

Specification