HTTP 204 · 2XX RFC 9110 §15.3.5 Cacheable: No Retryable: Depends on method

HTTP 204 No Content: Root Causes & Production Fix Guide

HTTP 204 No Content signals success with an intentionally empty response body. It is the gold standard for CORS OPTIONS preflight responses, DELETE operations, and beacon endpoints.

Top Root Causes of HTTP 204

Nginx CORS Preflight 204 No Content Block

if ($request_method = 'OPTIONS') {
    add_header Access-Control-Allow-Origin "https://app.example.com" always;
    add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
    add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
    add_header Access-Control-Max-Age 86400 always;
    return 204;
}

Verify with cURL

curl -i -X OPTIONS -H 'Origin: https://app.example.com' -H 'Access-Control-Request-Method: POST' https://api.example.com/v1/items

Interactive Stack Diagnoser (HTTP 204)

Frequently Asked Questions

Why does fetch().json() fail on HTTP 204?

Because 204 responses carry zero bytes in the body. Check `if (res.status === 204) return null;` before calling `res.json()`.

Should CORS OPTIONS preflight return 200 or 204?

204 No Content is preferred by the Fetch specification because it avoids unnecessary payload parsing; legacy IE11 clients sometimes used 200.

Can a 204 response include Content-Length?

RFC 9110 forbids sending a Content-Length or Transfer-Encoding header with a non-zero body on 204 responses.

Related Status Guides & Header Tools