HTTP 451 Unavailable For Legal Reasons (RFC 7725) indicates the server is denying access due to a legal demand. Named after Ray Bradbury's Fahrenheit 451, this status is used for government censorship, court-ordered takedowns, DMCA notices, GDPR right-to-be-forgotten, and geo-blocking for legal compliance. The response SHOULD identify the legal authority making the demand via a Link header with rel='blocked-by'.
Response includes the status code, standard headers (including Content-Type), and a small diagnostic JSON body describing the request and returned status.
Simulator URL (copy in the app after load — not a normal link):
https://httpstatus.com/api/status/451
Example request:
curl -i "https://httpstatus.com/api/status/451"The server is denying access to the resource as a consequence of a legal demand.
On this code, Inspector focuses on semantics, headers, and correctness warnings that commonly affect clients and caches.
HTTP 451 Unavailable For Legal Reasons has specific technical implications for API design, caching, and client behavior. Understanding the precise semantics helps distinguish it from similar status codes and implement correct error handling. The response should include a descriptive body following a consistent error schema (like RFC 7807 Problem Details) so clients can programmatically handle the error.
// Handle 451 Unavailable For Legal Reasons in Express
app.use((err, req, res, next) => {
if (err.status === 451) {
return res.status(451).json({
type: 'https://api.example.com/errors/unavailable-for-legal-reasons',
title: 'Unavailable For Legal Reasons',
status: 451,
detail: err.message
});
}
next(err);
});from fastapi import HTTPException
# Raise 451 Unavailable For Legal Reasons
raise HTTPException(
status_code=451,
detail={
'type': 'unavailable_for_legal_reasons',
'message': 'Descriptive error for 451 Unavailable For Legal Reasons'
}
)// Spring Boot 451 Unavailable For Legal Reasons handling
@ExceptionHandler(CustomUnavailableForLegalReasonsException.class)
public ResponseEntity<ErrorResponse> handleUnavailableForLegalReasons(
CustomUnavailableForLegalReasonsException ex) {
return ResponseEntity.status(451)
.body(new ErrorResponse("Unavailable For Legal Reasons", ex.getMessage()));
}// Return 451 Unavailable For Legal Reasons
func errorHandler(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(451)
json.NewEncoder(w).Encode(map[string]any{
"status": 451,
"error": "Unavailable For Legal Reasons",
"message": message,
})
}