DevKits
405

Method Not Allowed

4xx Client Error

Last updated:

The HTTP method is known but not supported for this specific URL.

Description

The response MUST include an Allow header listing the supported methods for this URL. For example, sending POST to a GET-only endpoint should return 405 with `Allow: GET, HEAD`.

When to use

Return 405 when a route exists but doesn't support the requested method.

Specification

RFC 9110 §15.5.6

Examples

HTTP response
HTTP/1.1 405 Method Not Allowed
Content-Type: application/json

{"error":"Method Not Allowed"}
Node.js (Express)
res.status(405).json({ error: "Method Not Allowed" });
Go (net/http)
w.WriteHeader(http.StatusMethodNotAllowed)
Python (Flask)
return jsonify({"error": "Method Not Allowed"}), 405

Related status codes

All 4xx codes