HTTP status code 451 Unavailable For Legal Reasons indicates that the server is denying access to the requested resource due to legal demands such as court orders, government censorship, or legal takedown notices.
? Key Concepts
Client request is valid but legally restricted
Used for transparency instead of generic 403/404
Often linked to censorship or copyright enforcement
Defined in RFC 7725
? Syntax / Theory
The status code 451 is part of the 4xx client error class. It clearly communicates that the issue is legal, not technical.
? Code Example(s)
? View Code Example
// Node.js Express example sending HTTP 451
app.get("/restricted", (req, res) => {
res.status(451).send("Unavailable For Legal Reasons");
});
? Live Output / Explanation
Server Response
When accessing /restricted, the server responds with status code 451 and an explanatory message indicating legal restriction.
// Simple browser simulation of HTTP 451 logic
document.getElementById("demoBtn").addEventListener("click", () => {
const reason = document.getElementById("legalReason").value;
alert("Simulating HTTP 451: " + reason);
// In a real app, this would be a fetch() resulting in 451
});