405 Method Not Allowed
HTTP method (GET, POST, etc.) not allowed for this endpoint.
The request method is not supported for the requested resource.
What HTTP 405 Method Not Allowed Means
The request method is not supported for the requested resource.
HTTP method (GET, POST, etc.) not allowed for this endpoint.
Common Causes
- Using POST on GET-only endpoint
- Using GET on POST-only endpoint
- Method not implemented
How to Fix It (For Visitors)
- Contact the website administrator
How to Fix It (For Developers/Admins)
- Check API documentation for allowed methods
- Verify HTTP method in request
- Add Allow header in response
- Review route configuration
Common 405 Scenarios
- POST to a static file - nginx returns
405 Not Allowedwhen a form posts to a static HTML file. Point the form at a script or API endpoint. - Route only registered for GET - add a handler for the method you need (POST, PUT, PATCH, DELETE).
- CORS preflight - browsers send
OPTIONSbefore many cross-origin requests; the server must answer it. - IIS WebDAV module - on IIS, the WebDAV module can intercept PUT and DELETE requests to an API and answer 405. Remove the module or handler for that site if you do not use WebDAV.
A 405 response must include an Allow header listing the methods the resource supports, which tells you what the server expects.
Returning a 405 Method Not Allowed (Code Examples)
If you build APIs or web apps, here is how to send an HTTP 405 response and how to test for it:
Node.js (Express)
app.get('/resource', (req, res) => {
res.status(405).json({ error: 'Method Not Allowed' });
});
Python (Flask)
@app.route('/resource')
def resource():
return jsonify(error='Method Not Allowed'), 405
PHP
<?php
http_response_code(405);
header('Content-Type: application/json');
echo json_encode(['error' => 'Method Not Allowed']);
Check the status with curl
curl -I https://example.com/resource
# Look for: HTTP/1.1 405 Method Not Allowed
Frequently Asked Questions
What does HTTP 405 Method Not Allowed mean?
HTTP method (GET, POST, etc.) not allowed for this endpoint. In short: The request method is not supported for the requested resource.
Is 405 Method Not Allowed a client or server error?
405 is a 4xx client-error code, so the request itself needs to change. The server is running normally and is rejecting the request as it was sent by the browser, app, or API client.
How do I fix a 405 Method Not Allowed error?
Check API documentation for allowed methods. Verify HTTP method in request. Add Allow header in response.
Official Specification
The 405 Method Not Allowed status code is defined in RFC 9110 Section 15.5.6.