405
HTTPERRORNotable4xx Client ErrorHIGH confidence

Method Not Allowed

Production Risk

Low. This is a clear, specific error that tells developers exactly what is wrong with their request method. It rarely indicates a server failure.

What this means

The request method is known by the server but has been disabled and cannot be used for that resource. The response must include an 'Allow' header containing a list of valid methods for the requested resource.

Why it happens
  1. 1A client attempts to use POST on a resource that only accepts GET.
  2. 2A client tries to DELETE a resource that is read-only.
  3. 3An API endpoint is configured to only respond to specific HTTP verbs.
How to reproduce

A client sends a PUT request to an API endpoint that is configured to only allow GET and POST requests.

trigger — this will error
trigger — this will error
PUT /api/users/123 HTTP/1.1
Host: example.com

expected output

HTTP/1.1 405 Method Not Allowed
Allow: GET, POST

Fix 1

Use a Supported HTTP Method

WHEN You control the client.

Use a Supported HTTP Method
Check the 'Allow' header in the response and change the request method accordingly.

Why this works

Client-Side Correction

Fix 2

Configure Allowed Methods on Server

WHEN You control the server.

Configure Allowed Methods on Server
// Example in an Express.js router
router.route('/users/:id')
  .get(getUser)   // GET is allowed
  .put(updateUser); // PUT is allowed, not POST

Why this works

Server-Side Routing

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors