508

HTTP 508 Loop Detected

5xx Server Error

5xx Server Error RFC 5842, Section 7.2

What is HTTP 508 Loop Detected?

The 508 (Loop Detected) status code indicates that the server terminated an operation because it encountered an infinite loop while processing a request. This is used in WebDAV to detect and break infinite binding loops.

Common Use Cases

  • WebDAV binding loop detection
  • Infinite redirect detection

Usage Example

When a WebDAV server detects that a request would create an infinite loop through circular bindings, it returns 508 Loop Detected. This can also be used in redirect middleware to detect and break redirect chains that exceed a reasonable limit.

// Middleware to detect redirect loops
$_redirectCount = $_SERVER['HTTP_X_REDIRECT_COUNT'] ?? 0;
if ($_redirectCount > 10) {
    http_response_code(508);
    echo json_encode(['error' => 'Redirect loop detected']);
    exit;
}
Last updated: 21 Jun 2026