418I'm a teapot
HTTP 418 is the status code a teapot returns when you ask it to brew coffee. This server is a teapot: request /coffee and it answers with a real 418.
$ curl -I https://tea.http418.nl/coffee HTTP/2 418
Where 418 comes from
On 1 April 1998, Larry Masinter published RFC 2324: the Hyper Text Coffee Pot Control Protocol, or HTCPCP. It describes how to control coffee pots over the web, with a BREW method and an Accept-Additions header for milk, syrup and whisky.
Section 2.3.2 adds a single new error. Any attempt to brew coffee with a teapot should result in 418 I'm a teapot. In 2014, RFC 7168 extended the protocol to tea, so teapots finally got something to do besides refuse.
Is 418 a real HTTP status code?
Not officially. HTCPCP was an April Fools' joke, and 418 was never part of HTTP itself. It found its way into Node.js, Go, ASP.NET and many other HTTP libraries anyway.
In August 2017, the chair of the IETF HTTP working group asked those projects to remove it. A teenage developer answered with save418.com, the Save 418 Movement went viral, and every project kept the code. The HTTP specification now lists 418 as reserved, so no real status code can ever take the number. Python added HTTPStatus.IM_A_TEAPOT in 3.9.
Google's teapot
Google has hosted its own teapot at google.com/teapot: the page answers with HTTP status 418, and clicking the teapot, or tilting your phone, makes it pour. (Search Engine Land)
Try it with curl
Need a URL that returns a real 418, to test an HTTP client or an error handler? This one is stable and always refuses coffee:
$ curl -I https://tea.http418.nl/coffee HTTP/2 418
The teapot also honours the Accept-Additions header from RFC 2324. Ask for an addition it doesn't have and you get 406 Not Acceptable, plus a list of what it does accept:
$ curl -i -H "Accept-Additions: Whole-milk" https://tea.http418.nl/tea HTTP/2 406
There is one tea that takes milk. Finding it is left as an exercise for the reader.
How to return 418 I'm a teapot
Want your own server to refuse coffee? Every common stack can send a 418. Over HTTP/2 there is no reason phrase, so clients only see the number.
nginx
location = /coffee {
return 418 "I'm a teapot\n";
}
Apache (mod_asis)
# /var/www/coffee.asis Status: 418 I'm a teapot Content-Type: text/plain I'm a teapot. # in the vhost AddHandler send-as-is asis Alias /coffee /var/www/coffee.asis
Node.js and Express
app.get("/coffee", (req, res) => res.status(418).send("I'm a teapot"));
Python and Flask
@app.route("/coffee")
def coffee():
return "I'm a teapot", 418
Django
from django.http import HttpResponse
def coffee(request):
return HttpResponse("I'm a teapot", status=418)
Go
http.HandleFunc("/coffee", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "I'm a teapot", http.StatusTeapot)
})
PHP
<?php http_response_code(418); echo "I'm a teapot";
Cloudflare Workers
export default {
fetch() {
return new Response("I'm a teapot", { status: 418 });
},
};
The constant for 418 in Node.js, Go, Python, .NET, Spring and Rust is listed on htcpcp.nl.