Skip to content

405 Method Not Allowed explained

By the ProxyOnly team · 25 Nov 2026 · 5 min read

A 405 means the URL exists but rejects your HTTP method. The Allow header says which methods work, and most 405s come from one of five causes.

A 405 Method Not Allowed means the server recognised the URL but will not accept the HTTP method you sent to it. You asked a valid address to do something it does not do.

RFC 9110 adds a requirement that most people miss: the server must generate an Allow header field containing the supported methods. A 405 without an Allow header is a non-conforming response, and when you are debugging someone else's API that header is the fastest answer available.

See it happen

Here is a small server where /doc accepts GET and PUT, and a client that sends POST:

def do_POST(self):
    self._send(405, b"use PUT", [("Allow", "GET, PUT")])

Sending a POST to it returns:

405 Allow: GET, PUT | use PUT

The header did the work. Two methods are supported, POST is not one of them, and no guessing was required.

So the first thing to do with any 405 is read that header. In curl, -i shows it:

curl -i -X POST https://api.example.org/doc

The methods, and which ones a server usually accepts

It helps to know the full set, because a 405 is a statement about one of them.

  • GET: fetch a resource. Safe, and cacheable.
  • HEAD: the same as GET but headers only. A server that supports GET should support HEAD.
  • POST: submit data, usually creating something or triggering an action.
  • PUT: replace a resource entirely at a known URL.
  • PATCH: change part of a resource.
  • DELETE: remove it.
  • OPTIONS: ask what is supported. This is the one browsers send on their own.
  • TRACE and CONNECT: diagnostics and tunnelling. CONNECT is how an HTTP proxy opens an HTTPS tunnel, which is why it appears in proxy logs and almost nowhere else.

GET, HEAD and OPTIONS are safe methods, meaning they are not supposed to change anything. GET, HEAD, PUT and DELETE are idempotent, meaning sending the same request twice has the same effect as sending it once. POST and PATCH are neither, which is exactly why a redirect that silently converts a POST into a GET is such a problem.

If you are curious what your own client sends and how a proxy sees it, what is curl covers reading a request on the wire.

Why 405 is not 404 or 501

  • 404 Not Found: the server has nothing at that path, for any method.
  • 405 Method Not Allowed: the path exists, the method does not apply to it.
  • 501 Not Implemented: the server does not support the method at all, anywhere.

That middle one is the useful signal. A 405 is a confirmation that you found the right URL. Many people see a 405 and start hunting for a different endpoint when they already had it.

The five common causes

You sent POST to a route defined for GET

The plain case. A framework route declared for one method answers 405 for the rest. Flask, Express, Django and Rails all behave this way.

A trailing slash changed the route

Frameworks often redirect /items to /items/ with a 301 or 308. A 301 tells clients they may switch to GET, so a POST becomes a GET on the redirect, and the destination then answers 405 because it has no GET handler for that action. The giveaway is a 405 that only happens on POST and never on GET. Fix it by using the exact URL the API documents, slash included, instead of relying on the redirect.

A CORS preflight is being blocked

Before certain cross-origin requests, browsers send an OPTIONS request. If the server has no OPTIONS handler, it answers 405 and the real request never happens. In the browser console this looks like a CORS failure, but the network tab shows a 405 on an OPTIONS you did not write. The fix is on the server: handle OPTIONS and answer with the appropriate Access-Control-Allow-* headers.

A static host is being asked to accept a form

Static hosting serves files and answers GET and HEAD. Point an HTML form at a static host and the POST comes back 405. The same happens on a CDN path configured for static assets. Forms need something that runs code: a function, an API route, or a form service.

The server-level configuration forbids the method

IIS with WebDAV installed is the classic one. The WebDAV module intercepts PUT and DELETE before the application sees them and answers 405. Microsoft's IIS documentation covers the request filtering that controls which verbs are permitted. nginx can produce the same effect with limit_except, and some WAF rules block PUT, DELETE and PATCH by default.

If you are building the API

Always send the Allow header. It is a required part of the response and it saves the person on the other end a support ticket.

Answer OPTIONS on every route that a browser will call cross-origin.

Prefer 405 over 404 when the path exists. Hiding the existence of a route behind a 404 is sometimes a deliberate security choice, but if you are not making that choice deliberately, the 405 is more useful.

Be consistent about trailing slashes, and document which form you expect.

If a script or scraper gets a 405

Read the Allow header before changing anything else.

Check whether a redirect is rewriting your method. In requests, the history shows it:

import requests
r = requests.post("https://httpbin.org/redirect-to?url=/get&status_code=301", timeout=10)
print("final", r.status_code, "method now:", r.request.method)
for hop in r.history:
    print("  hop:", hop.status_code, hop.request.method)

We ran that and it printed final 200 method now: GET with a hop of 301 POST. The POST was sent, the server answered 301, and the client followed it with a GET. If the destination has no GET handler, that is your 405, and nothing in your own code looks wrong. Use allow_redirects=False to see the first response untouched.

Confirm you are sending what you think. A client configured with a default method, or an HTTP library that quietly converts a POST without a body into a GET, produces a 405 that looks inexplicable from the calling code.

Do not retry a 405 and do not rotate IP addresses at it. Like a 400, it is a statement about your request, not about you. Waiting does not change the method you sent. Our proxy errors guide covers the errors where rotating actually is the answer, and this is not one of them.

Try it yourself

Create an account, add funds from US$1 and order a proxy in the country you need.

Keep reading