405 Method Not Allowed: right URL, wrong method

405 Method Not Allowed means the server knows the request method but the target URL doesn’t support it; the Allow header lists what does work.

Check a URL’s status code

405 Method Not Allowed means the server knows the HTTP method you used (POST, PUT, DELETE, even HEAD) but this particular URL doesn’t accept it. The page or endpoint exists; it just won’t take that kind of request.

Definition

RFC 9110, section 15.5.6 requires the server to include an Allow header listing the methods the resource does support. Compare 501 Not Implemented, which means the server doesn’t support the method anywhere. RFC 9110 also says every general-purpose server must support GET and HEAD, so a 405 on either of those is a bug.

Common causes

  • A form posts to a URL whose route only accepts GET, or the form’s action points at the wrong path.
  • POSTing to a static file: Nginx answers 405 because a static file can’t receive a POST.
  • Application routes that don’t answer HEAD. Express, Laravel and Flask handle HEAD automatically for GET routes; some custom routers don’t.
  • Hosts or WAFs that block PUT, DELETE or WebDAV methods.

SEO impact

Googlebot fetches pages with GET, so a 405 only hurts if GET itself is rejected. Then the URL is treated like any other 4xx and drops out of the index, per Google’s documentation. A subtler problem: if HEAD returns 405 while GET returns 200, uptime monitors and link checkers that rely on HEAD may report working pages as broken links. Fix HEAD support so every tool sees the truth.

How to fix it

// Express: explicit 405 with an Allow header for other methods
app.route('/api/v1/reports')
  .get(listReports)
  .post(createReport)
  .all((req, res) => {
    res.set('Allow', 'GET, HEAD, POST').status(405).json({ error: 'Method not allowed' });
  });

For forms, check that the method attribute and the server route match. On a static site, send forms to a script or form service, not to an .html file.

How to check

The HTTP status checker confirms what a normal page request returns, and the HTTP header checker shows the full response headers. To test a specific method, use curl:

curl -i -X POST https://www.example.com/about.html

HTTP/1.1 405 Not Allowed
Server: nginx
Content-Type: text/html

Nginx prints its own reason phrase, “Not Allowed”; clients go by the number, so it means the same as “Method Not Allowed.”

Frequently asked questions

What is the difference between 405 and 404?

404 means nothing exists at the URL. 405 means something does exist there, but it doesn’t accept the method you used, such as a POST to a page that only supports GET.

Why does my contact form return 405?

The form is probably posting to a URL that only accepts GET, often a static HTML page or a route defined for GET only. Point the form’s action at the script or route that handles POST.

Does a 405 on HEAD requests affect Google?

Not directly, because Googlebot fetches pages with GET. It still matters: monitors and checkers that use HEAD may report the page as broken, and the HTTP spec requires servers to support HEAD.