204 No Content
Fault: Neither
TL;DR
Request successful but no content to return.
The server successfully processed the request but is not returning any content.
What This Error Means
The server successfully processed the request but is not returning any content.
Request successful but no content to return.
Common Causes
- Successful DELETE request
- Successful PUT/PATCH with no response body
- Form submission with no redirect
How to Fix It (For Visitors)
- No action needed - operation successful
How to Fix It (For Developers/Admins)
- Return 204 for successful DELETE operations
- Use when no response body is needed
Code Examples
Here's how to return a 204 status code in various programming languages:
Python (Flask)
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/endpoint')
def endpoint():
return jsonify({"message": "No Content"}), 204
Node.js (Express)
const express = require('express');
const app = express();
app.get('/endpoint', (req, res) => {
res.status(204).json({ message: 'No Content' });
});
PHP
<?php
http_response_code(204);
header('Content-Type: application/json');
echo json_encode(['message' => 'No Content']);
?>
Go
package main
import (
"encoding/json"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(204)
json.NewEncoder(w).Encode(map[string]string{
"message": "No Content",
})
}
Java (Spring Boot)
@GetMapping("/endpoint")
public ResponseEntity<Map<String, String>> endpoint() {
Map<String, String> response = new HashMap<>();
response.put("message", "No Content");
return ResponseEntity.status(204).body(response);
}
Ruby (Sinatra)
get '/endpoint' do
status 204
json message: 'No Content'
end
Browser Compatibility
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✓ Full Support | All versions |
| Firefox | ✓ Full Support | All versions |
| Safari | ✓ Full Support | All versions |
| Edge | ✓ Full Support | All versions |
Official Specification
This status code is defined in RFC 7231 Section 6.3.5.