Success, with nothing to send back.
When to use it
A DELETE or PUT that doesn’t return a body.
Good to know
A 204 must not have a body. If your framework writes JSON anyway, HTTP/1.1 clients and proxies may read the extra bytes as the start of the next response, which breaks keep-alive connections in confusing ways. In fetch, response.ok is true for 204 but response.json() throws on the empty body, so check for status 204 before parsing.
In a browser, a link or form submission that returns 204 leaves the current page untouched: no navigation, no error. That makes it handy for beacons and tracking endpoints. 204 is also the usual answer to a CORS preflight OPTIONS request. Don’t use it for a GET that found nothing; return 404, or 200 with an empty list, so clients can tell the cases apart.
Success (2xx)
2xx codes mean success: the server received, understood and accepted the request.
What it looks like
HTTP/1.1 204 No ContentHow to send it
| Node.js / Express | res.status(204).end() |
|---|---|
| Python / Flask | return '', 204 |
| nginx | return 204; |
How to check it
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/