HTTP/4xx (Client Error)
405 Method Not Allowed
The request method is recognized by the server but is not supported by the target resource.
❓ Why does this happen?
Sending a POST or PUT request to a route that only accepts GET, or vice versa.
✅ How to fix it
Check the Allow response header to identify supported HTTP methods for that endpoint.
Return or handle 405 in your stack
// app/api/resource/route.ts
export function GET() {
return Response.json(
{ error: "Method Not Allowed", status: 405 },
{
status: 405,
headers: { "Allow": "GET, POST" }
}
);
}Live 405 mock endpoint
Point your app, tests, or retry logic at this free public URL to reproduce a real 405 response (CORS enabled, optional ?delay=ms up to 5000).
https://castov.com/api/mock/405Frequently Asked Questions
What does HTTP Status 405 mean?
Why am I getting a 405 status code?
How do I fix a 405 Method Not Allowed error?
How can I test how my app handles a 405 response?
Other 4xx status codes
Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.