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.
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.
- 1A client attempts to use POST on a resource that only accepts GET.
- 2A client tries to DELETE a resource that is read-only.
- 3An API endpoint is configured to only respond to specific HTTP verbs.
A client sends a PUT request to an API endpoint that is configured to only allow GET and POST requests.
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.
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.
// Example in an Express.js router
router.route('/users/:id')
.get(getUser) // GET is allowed
.put(updateUser); // PUT is allowed, not POSTWhy this works
Server-Side Routing
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev