4xx Client ErrorCommonly usedRFC 9110
405Method Not Allowed
HTTP method is not supported for this endpoint.
What it means
The HTTP method used in the request is not supported by the resource. For example, sending a DELETE to an endpoint that only supports GET and POST. The response must include an Allow header listing the supported methods.
When to use it
- ✓Endpoint only accepts GET but received POST
- ✓Read-only resource received a write request
- ✓DELETE not supported on a resource
Common causes
- →Wrong HTTP method in fetch/axios call
- →Misconfigured API client
- →Form submitting POST to a GET-only endpoint
Code Examples
Express — allowed methods
javascript
app.all('/users', (req, res, next) => {
if (!['GET', 'POST'].includes(req.method)) {
return res.status(405)
.set('Allow', 'GET, POST')
.json({ error: 'Method not allowed' });
}
next();
});Don't confuse with
Quick Facts
Code405
CategoryClient Error
SpecRFC 9110
CommonYes
Relevant Headers
Allow
Lists the HTTP methods supported by the resource (e.g. GET, POST)