405 Method Not Allowed: What It Means & How to Fix It

Key takeaway

405 Method Not Allowed means the server recognises the URL but doesn't accept the HTTP method you used there, for example a POST sent to a page that only accepts GET. RFC 9110 requires the server to list the methods it does accept in an Allow header, so start by reading that header. Typical causes are a form or API call using the wrong method, a POST to a static file on nginx, a route handler that doesn't export that method (Next.js, Flask, Django), WebDAV intercepting PUT and DELETE on IIS, and CORS preflight OPTIONS requests the server doesn't handle.

Check it now

405 Not Allowed nginx error page next to the step-by-step fixes for 405 Method Not Allowed
405 Not Allowed nginx error page next to the step-by-step fixes for 405 Method Not Allowed
Start reading
  1. What Is a 405 Method Not Allowed Error?
  2. What a 405 Error Looks Like
  3. Step 1: Read the Allow Header
  4. If You're a Visitor
  5. Fix 1: Send the Right Method to the Right URL
  6. Fix 2: nginx Returns 405 for POST to Static Files
  7. Fix 3: IIS Blocks PUT and DELETE (WebDAV)
  8. Fix 4: Add the Method to Your Route Handler
  9. Fix 5: Handle CORS Preflight (OPTIONS) Requests
  10. 405 vs 400, 403, 404 and 501
  11. Frequently Asked Questions

What Is a 405 Method Not Allowed Error?

405 Method Not Allowed is an HTTP status code meaning the server knows the address you requested, but doesn't allow the method your request used. RFC 9110 defines it as the method being "known by the origin server but not supported by the target resource" (RFC 9110 §15.5.6).

Every HTTP request has a method: GET to read a page, POST to submit a form or create something, PUT and PATCH to update, DELETE to remove, OPTIONS to ask what's allowed. A 405 means the URL exists, but not for that verb. If the URL didn't exist at all, you'd get 404 instead.

Because it's about how a request was made rather than about a missing page, a 405 is almost always something for the site's developer to fix. Visitors usually hit it after submitting a form or following an outdated link.

Check the status and headers a URL returns

What a 405 Error Looks Like

Server / frameworkTypical message
nginx405 Not Allowed (with nginx underneath, and no Allow header)
ApacheMethod Not Allowed. The requested method PUT is not allowed for this URL. (with an Allow header)
IISHTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Next.js / APIsAn empty or JSON response with status 405, often visible only in DevTools
Browser console (CORS)A CORS error, because the OPTIONS preflight received a 405

Step 1: Read the Allow Header

Ask the server which methods it accepts for that URL. Either send an OPTIONS request, or repeat the failing request with headers shown:

bash
# Which methods does this URL accept?
curl -i -X OPTIONS https://example.com/api/contact

# Repeat the failing request and look at the status and Allow header
curl -i -X POST https://example.com/api/contact -d 'name=test'
# HTTP/2 405
# allow: GET, HEAD

DNS Robot's HTTP Header Checker shows the status code and headers a URL returns to a normal GET request, which helps when you're checking a page in the browser rather than an API.

Not every server follows the rule. nginx's built-in 405 page, for example, is sent without an Allow header (a POST to nginx.org's own static pages shows it), and so is the empty 405 a Next.js route handler returns; Apache includes one. On Next.js, curl -i -X OPTIONS still lists the methods, because Next.js answers OPTIONS itself. On nginx you'll need to check which location block handles the URL instead (Fix 2).

If You're a Visitor

  • Go back and reload the page, then submit the form again. A form loaded from an old cached copy can post to an address that has since changed.
  • Don't resubmit by refreshing. If the error appeared right after you sent a form, refreshing only repeats the same rejected request; go back, reload the form page and submit from there.
  • Check the address for a typo, or open the site's homepage and navigate again.
  • Report it. If a form on the site always fails, the site owner needs to fix it, so send them the page address.

Fix 1: Send the Right Method to the Right URL

A common cause in code is simply a mismatch: a form or fetch() call uses POST while the endpoint only accepts GET, or the request goes to the page URL instead of the API URL. Compare the method in your code with the Allow header and the API's documentation.

javascript
// The endpoint only allows POST, so a GET (the default for fetch) returns 405
const res = await fetch("/api/contact", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "Ana" }),
})
if (res.status === 405) console.log("Allowed:", res.headers.get("allow"))

Fix 2: nginx Returns 405 for POST to Static Files

nginx's static file handler only serves GET and HEAD. A POST to an .html file, or to a location that serves files instead of passing the request to your application, gets 405 Not Allowed. This often happens when a form's action points at a static page, or when a location block meant for your app doesn't match.

The real fix is to send the POST to an application (PHP, Node, Python) with proxy_pass or fastcgi_pass in the right location block, for example:

nginx
# Form posts must reach the app, not the static file handler
location /api/ {
    proxy_pass http://127.0.0.1:3000;
}

# Test and reload after changes
# sudo nginx -t && sudo systemctl reload nginx

Fix 3: IIS Blocks PUT and DELETE (WebDAV)

On Windows servers running IIS, the WebDAV module claims the PUT and DELETE verbs, so REST APIs (ASP.NET Web API and others) answer HTTP Error 405.0 for them. If you don't use WebDAV, remove it for your site in web.config:

xml
<system.webServer>
  <modules>
    <remove name="WebDAVModule" />
  </modules>
  <handlers>
    <remove name="WebDAV" />
  </handlers>
</system.webServer>

Also check the site's Request Filtering settings in IIS Manager (HTTP Verbs tab), which can deny specific methods outright (IIS reports those as 404.6, not 405).

Fix 4: Add the Method to Your Route Handler

Frameworks return 405 when a route exists but has no handler for the method used:

  • Next.js (App Router): a route.ts answers only the methods it exports (plus HEAD and OPTIONS, which Next.js adds itself). If it exports GET but not POST, a POST returns 405. Add export async function POST(request: Request) { … }.
  • Flask: routes accept only GET by default. Use @app.route("/contact", methods=["GET", "POST"]).
  • Django: class-based views return 405 for methods without a matching handler (add a post() method), and the require_http_methods decorator does the same.
  • Express: by default an unmatched method falls through to 404, not 405. If your API should return 405, add a catch-all handler that sets the Allow header.

Fix 5: Handle CORS Preflight (OPTIONS) Requests

When a web page calls an API on another domain with JSON or custom headers, the browser first sends an OPTIONS preflight request. If the API answers that OPTIONS request with 405, the browser reports a CORS error and never sends the real request, even though the real endpoint would have worked.

Make the API answer OPTIONS for those routes with a 204 or 200 and the right Access-Control-Allow-Methods and Access-Control-Allow-Headers headers. Most frameworks have CORS middleware that does this for you. DNS Robot's own public API, for example, answers the preflight through its CORS middleware and any other method it doesn't support with 405 and Allow: GET, OPTIONS.

405 vs 400, 403, 404 and 501

CodeMeaning
405 Method Not AllowedThe URL exists, but not for this method
400 Bad RequestThe request itself is malformed
403 ForbiddenThe server understood you but won't allow access
404 Not FoundNothing exists at this URL
501 Not ImplementedThe server doesn't support this method for any URL

Related guides: 400 Bad Request, 403 Forbidden and 401 Unauthorized.

Check what a URL returns

DNS Robot's HTTP Header Checker shows the status code and response headers a URL returns to a GET request, so you can confirm what a page answers and see the server software behind it.

Sources

  1. RFC 9110 §15.5.6: 405 Method Not Allowed, IETF
  2. RFC 9110 §15.4: Redirection 3xx, IETF
  3. Route Handlers, Next.js

Frequently Asked Questions

What does 405 Method Not Allowed mean?

It means the server recognises the URL but doesn't accept the HTTP method used, such as a POST sent to a page that only allows GET. The response should include an Allow header listing the methods that URL does accept.

How do I fix a 405 error?

Read the Allow header (curl -i -X OPTIONS <url>) and send a method from that list to the right URL. On the server side, add a handler for the method, route POSTs to your application instead of static files in nginx, remove WebDAV on IIS if it blocks PUT and DELETE, and handle CORS preflight OPTIONS requests.

Why do I get 405 Method Not Allowed on a POST request?

The endpoint doesn't accept POST: the route has no POST handler, the request goes to a static file (nginx answers 405 Not Allowed), or a redirect turned your POST into a GET to a different URL. Check the Allow header and the exact URL.

What is 405 Not Allowed in nginx?

nginx returns 405 Not Allowed when a POST or another unsupported method reaches its static file handler, which only serves GET and HEAD. Make sure the URL is handled by a location block that passes the request to your application.

How do I fix HTTP Error 405.0 in IIS?

IIS's WebDAV module often blocks PUT and DELETE. Remove WebDAVModule from modules and the WebDAV handler from handlers in web.config, and check the HTTP Verbs tab under Request Filtering.

Can a CORS problem cause a 405?

Yes. Browsers send an OPTIONS preflight before many cross-origin API calls. If the server answers OPTIONS with 405, the browser shows a CORS error. Handle OPTIONS with the right Access-Control headers.

What is the difference between 405 and 404?

404 means nothing exists at the URL. 405 means the URL exists, but not for the method you used.

What is the difference between 405 and 501?

405 means this URL doesn't support the method. 501 Not Implemented means the server doesn't support the method for any URL at all.

Does a 405 error affect SEO?

Only if Googlebot gets 405 for pages you want indexed. Googlebot requests pages with GET, so a 405 usually affects forms and APIs, not crawling. Make sure your normal pages answer GET with 200.

About the author

Shaik Vahid

Founder of DNS Robot. Vahid spent years in web hosting support fixing domains, DNS records, SSL certificates and email delivery for customers. He builds DNS Robot's tools and writes these guides from the errors people actually hit.

HTTP Header Checker

Response headers exactly as sent, with a Mozilla Observatory security grade