204 No Content

HTTP Status CodesSuccess (2xx)commonStatus Code: 204Last updated: todayTested on:Google ChromeNode.js v20 LTSJune 2026

The request has succeeded but there is no payload body to return.

204 No Content Quick Fix⏱️ Est. Fix Time: 3 minutes

Usually happens because:

  • Successful DELETE requests removing resources
  • Successful PUT/PATCH requests updating database
  • CORS preflight OPTIONS requests returning

🔍 Quick Checklist:

Meaning

The HTTP 204 No Content success status code indicates that the request has succeeded, but that the client doesn't need to navigate away from its current page. It is commonly used in REST APIs for DELETE or PUT requests where returning a resource representation is unnecessary.

Root Causes

  • Successful DELETE requests removing resources from databases.
  • Successful PUT/PATCH requests updating database fields where client-side representations are already up-to-date.
  • CORS preflight OPTIONS requests returning success confirmation headers.
CauseFrequency
Successful DELETE requests removing resources⭐⭐⭐⭐⭐
Successful PUT/PATCH requests updating database⭐⭐⭐⭐
CORS preflight OPTIONS requests returning⭐⭐⭐

Common Mistakes

  • Sending JSON response payload content resulting in client parser errors.
  • Misconfiguring CORS responses with 200 instead of 204 OPTIONS preflights.

How to Fix

1Ensure the server does not send a response body payload for a 204 status, otherwise clients may fail to parse it.
2Configure client fetch libraries to handle empty payload body streams correctly.

Framework-Specific Examples

Returning 204 No Content for a delete route in Express.

Express Example
app.delete('/api/users/:id', (req, res) => {
  res.status(204).end();
});

Server Configuration Examples

Returning 204 No Content immediately for CORS OPTIONS preflights.

Nginx Config
if ($request_method = 'OPTIONS') { return 204; }

Prevention

  • Use .end() in Express or null bodies in modern framework responses.
  • Verify HTTP spec compliance with automated testing frameworks.

Frequently Asked Questions (FAQ)

Q: Are there any size restrictions for 204 No Content responses?

A 204 response must not contain a message body. Any headers specifying content-length or transfer-encoding are either omitted or set to 0.

Q: Why does my fetch request fail on a 204 No Content response?

Many frontend libraries fail if they automatically run 'response.json()' on an empty 204 stream. You must check status first before attempting body decoding.

Q: When should I use 204 over 200 in a REST API?

Use 204 No Content for DELETE actions or updates that do not result in a new object representation required by the UI.

Q: Can Nginx return 204 responses directly?

Yes, Nginx is commonly configured to return 204 directly for health check paths (/health) or cross-origin preflight requests.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error