HTTP status code 418 – I'm a Teapot is a humorous response code defined in an April Fools' RFC. It indicates that the server refuses to brew coffee because it is, quite literally, a teapot.
HTTP status codes are three-digit numbers returned by servers to indicate the result of a request. The 418 code belongs to the 4xx Client Error category, even though its meaning is intentionally absurd.
// Example of sending HTTP 418 from a Node.js server
const http = require("http");
http.createServer((req, res) => {
res.writeHead(418, { "Content-Type": "text/plain" });
res.end("I'm a teapot ☕");
}).listen(3000);
When a client accesses this server, it receives a 418 status code along with the message "I'm a teapot ☕", demonstrating how custom status codes can be sent.
// Simulate an HTTP 418 response in the browser
function simulateTeapot() {
const output = document.getElementById("teapotOutput");
output.textContent = "Brewing...";
setTimeout(() => {
output.textContent = "Error 418: I'm a teapot ☕";
output.style.color = "var(--danger)";
}, 1000);
}
Click the button below to attempt brewing coffee on this server: