204 No Content
The request succeeded, but there is no body to return.
Meaning & Description
Common Causes
- A standard, successful operation that by design does not return data.
How to fix a 204 error
- If you expected data, ensure the endpoint isn't designed to return 204. Check the API documentation.
- If your frontend HTTP client throws a JSON parsing error, it is likely because it tried to parse the empty body of a 204 response. Ensure your client handles 204s safely.
Browser & SEO Behaviour
Browser Behavior
If a form submission results in a 204, the browser will stay on the current page and will not refresh or navigate. This is highly useful for background actions.
SEO Impact
Neutral. Crawlers expect 200 OK for content. Returning 204 for a GET request to a webpage will result in a blank page.
CDN Behavior
CDNs generally do not cache 204 responses unless explicitly configured, as they usually result from state-changing verbs (PUT, DELETE).
Code Examples
HTTP/1.1 204 No Content
Date: Mon, 23 May 2026 22:38:34 GMT
app.delete('/api/users/:id', async (req, res) => {
await db.users.delete(req.params.id);
// Send 204 No Content with no body
res.status(204).end();
});from fastapi import FastAPI, status
app = FastAPI()
@app.delete("/api/users/{user_id}", status_code=status.HTTP_204_NO_CONTENT)
def delete_user(user_id: int):
# Delete user logic here
return None # Must return nothingfunc deleteUser(w http.ResponseWriter, r *http.Request) {
// Delete logic...
w.WriteHeader(http.StatusNoContent)
// Do not write anything to the body
}[HttpDelete("{id}")]
public IActionResult DeleteUser(int id)
{
_repository.Delete(id);
return NoContent(); // Returns 204
}curl -X DELETE https://api.example.com/users/123 -iRaw HTTP Response Example
HTTP/1.1 204 No Content
Date: Mon, 23 May 2026 22:38:34 GMTReal-world Examples
Frequently Asked Questions
Can a 204 response contain a body?
No. The HTTP specification strictly forbids a 204 No Content response from containing a message body. Any attempt to include one is a violation of the protocol and may cause client-side errors.
Should I return 204 or 200 for a DELETE request?
If the DELETE request is successful and you do not return any data (like the deleted object state), return 204. If you choose to return a JSON object confirming the deletion or the state of the deleted item, you must return 200 OK.
Why does fetch() throw a JSON parsing error on 204 responses?
If your JavaScript code blindly calls `.json()` on a fetch response, it will crash on a 204 because the body is entirely empty (not even an empty `{}`). You should check `response.status === 204` before attempting to parse the body.
What happens if a GET request returns a 204?
While technically legal, it is highly unusual. A browser receiving a 204 from a top-level GET navigation will simply remain on the current page, showing no visual change to the user.
Is 204 appropriate for an empty array response?
No. If a query yields no results, returning `[]` is returning a payload. Therefore, you should return a 200 OK with the empty array. 204 means there is literally zero bytes of payload.
Did You Know?
Returning 200 OK with an empty body (`Content-Length: 0`) is technically valid, but 204 No Content is the much more semantic and universally recognized standard for this scenario.
Many web frameworks will automatically strip any response body you accidentally try to send if you set the status code to 204.
Developer Tips
- Always use 204 for DELETE operations unless you have a specific requirement to return the deleted object.
- When writing front-end HTTP interceptors (like in Axios or Fetch), always check for status 204 before attempting JSON deserialization to prevent hard crashes.
- Use 204 for telemetry endpoints. It saves bandwidth since neither headers like Content-Type nor a body are transmitted.
Interview Questions
These are questions you might face in a backend or API design interview that touch on HTTP 204.
Why would a REST API return a 204 No Content instead of a 200 OK?
A 204 No Content is used when the server has successfully processed the request but has no information to send back in the response body. This is standard practice for DELETE requests or PUT requests that do not echo the updated entity.
What happens if you try to return a JSON body with a 204 status code?
It violates the HTTP specification. A 204 response must not contain a message body. Depending on the client or proxy, it may lead to protocol errors, dropped connections, or HTTP request smuggling vulnerabilities. Most modern backend frameworks will actively prevent you from writing to the body of a 204.
Common Interview Mistakes
- Stating that 204 means the resource was "not found". That is 404 Not Found. 204 is a success code.
- Saying that a GET request returning an empty array should use 204. An empty array `[]` is data, and should return 200 OK.