When you see this status
- Client sends a request with an unsupported HTTP method (e.g., POST to a read-only endpoint)
- Server explicitly rejects a method via Allow header restrictions
- API versioning conflicts prevent method usage
Common causes
- Incorrect HTTP method in client request (e.g., GET vs POST)
- Server-side route misconfiguration
- Missing or misconfigured CORS preflight handling
- API endpoint does not support the requested method
How to debug it
- Verify the HTTP method used in the request
- Check server route definitions for method support
- Inspect the Allow header in the response
- Test with curl: `curl -X <method> <url>`
- Review server logs for route resolution failures
Return this code in your framework
Express (Node.js)
app.all('/resource', (req, res) => res.status(405).set('Allow', 'GET').send());
FastAPI (Python)
from fastapi import FastAPI, status
app = FastAPI()
@app.post('/resource')
async def handle_post(): return JSONResponse(status_code=405, headers={'Allow': 'GET'})
NestJS
import { Controller, Post, HttpCode } from '@nestjs/common';
@Controller('resource')
export class ResourceController {
@Post() @HttpCode(405) handlePost() { return; }
}
Go (net/http)
http.HandleFunc("/resource", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
w.Header().Set("Allow", "GET")
http.Error(w, "Method Not Allowed", 405)
}
})
About HTTP 405
HTTP status code 405 Method Not Allowed is part of the
4xx Client Error family. The HTTP method used is not supported for the requested resource. Understanding it is essential for
backend engineers, API designers, and anyone debugging integrations between services.
The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance:
what triggers them, how to debug them in production, and exactly how to return them from common
frameworks. Each code page is hand-curated and verified.