204 No Content means: The request succeeded and there is deliberately no content to return. The response must not include a body; headers may still carry metadata. It is the idiomatic success code for DELETE and for actions whose result is 'done, nothing to show'. Success 2xx codes confirm the request was received, understood and accepted. The family distinguishes what kind of success happened — content returned, resource created, work queued, or nothing to return — and choosing the precise code is part of a well-designed API contract that clients and caches can rely on. In practice you will meet 204 when a delete removes a resource and returns nothing; a put/patch updates a resource and the client does not need the new representation; a form or beacon endpoint acknowledges an event with no payload. On the client side, do not attempt to parse a body (there is none); treat 204 as success. Note that browsers keep the current page on 204 form submissions. On the server side, send no body and no Content-Length describing one; if you need to return data, use 200 instead. 204 responses are cacheable by default.
When 204 happens
- A DELETE removes a resource and returns nothing
- A PUT/PATCH updates a resource and the client does not need the new representation
- A form or beacon endpoint acknowledges an event with no payload
How to fix it
On the client
Do not attempt to parse a body (there is none); treat 204 as success. Note that browsers keep the current page on 204 form submissions.
On the server
Send no body and no Content-Length describing one; if you need to return data, use 200 instead. 204 responses are cacheable by default.
Should you retry?
Success with no body — nothing to retry and nothing to parse.
Debugging steps
When 204 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Success codes rarely need debugging, but verify the body semantics match the code — a 200 wrapping an error payload is an API design bug, not a transport problem. For this code specifically, check whether the most common trigger applies to your situation: a delete removes a resource and returns nothing. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.
Notes & gotchas
A 204 with a body is a protocol violation that breaks connection framing; frameworks that auto-serialize return values are a common accidental source of this bug.
Examples
HTTP/1.1 204 No Content
curl -i https://api.example.com/v1/resource # observe the 204 response and its headers const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 204) {
// No Content: no body arrives — reuse cached state or treat as success.
return;
} import requests
res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 204:
pass # No Content: no body — reuse cached state / treat as success Frequently asked questions
Can 204 include a JSON body?
No. A 204 response must not contain content; any body is a protocol violation that confuses clients and intermediaries.
Is 204 idempotent-friendly?
Yes — DELETE returning 204 (or 404 on repeat) is the classic idempotent pattern; some APIs return 204 even when nothing existed to delete.
Which 2xx code should my API return?
200 for a normal result, 201 when a resource was created (with Location), 202 when work is queued, 204 when there is nothing to return. Precision here makes clients, caches and monitors behave correctly.
Can I treat any 2xx as interchangeable success?
For 'did it work' yes, but the distinctions matter operationally: 201 means a resource exists, 202 means work is still pending, 204 means there is no body to parse. Code that ignores them breaks.
Try the JSON Validator
Check JSON syntax and locate errors by line and column.