405

Method Not Allowed

4xx · Client Error common

Overview

405 Method Not Allowed is returned when the server recognizes the request's HTTP method but does not allow it for the target resource — for example sending GET to an endpoint that only accepts POST.

By spec a 405 response must include an Allow header listing the methods the resource actually supports, so the client knows which method to retry with.

When it happens

Request / Response example

Request
DELETE /api/articles HTTP/1.1
Host: api.example.com
Response
HTTP/1.1 405 Method Not Allowed
Allow: GET, POST
Content-Type: application/json

{"error":"method_not_allowed","allowed":["GET","POST"]}

In code

app.route('/api/articles')
  .get(list)
  .post(create)
  .all((req, res) => res.set('Allow', 'GET, POST').sendStatus(405));
location /api/articles {
    limit_except GET POST { deny all; }  # others -> 405
}

Common causes

How to fix

Notes

Related status codes

Related headers

Specification