405 Method Not Allowed
When error messages appear on your website, it is always unpleasant. There's a good chance that your visitor will get annoyed and leave, which can lead to a significant loss of revenue. One common error to look out for is the
405 Method Not Allowed message.
The problem with 405 errors is that they can be challenging to interpret. They let you know something went wrong, but they don't tell you what caused the problem. However, in most cases, it is possible to find the cause after a bit of troubleshooting and fix it.
What does a 405 Method Not Allowed error mean?
405 Method Not Allowed error is an HTTP response status that tells you that a web browser has made a request to access one of your website's pages. Your web server has received the request and recognized it but has rejected the specific HTTP method that was used.
405 error confirms that the requested page does exist, but the HTTP method used to make the initial request is not accepted.
This results in the browser not being able to access the requested page. Visitors to your website will therefore see an error page and not the content they were looking for.
The HTTP protocol uses what are called methods in order to determine which actions should take place on a web server. There are variety of HTTP methods; however, a few examples include:
GETRetrieves information from the web server that is defined by a specific URL.
POSTPost information to the web server, such as a comment on a forum.
PUTCreate or replace a resource based on the data the client submits to the web server (e.g., creating a new web page or updating an existing one).
DELETEDeletes the resource from the web server associated with a specific URL.
HTTP methods can be configured on the web server to determine which objects should be allowed or disallowed to use particular methods. If a method is not allowed throughout a site, it will return an HTTP
However, in the case of
405 Method Not Allowed, this error indicates that the web server is configured in a way that does not allow you to perform that action for a particular URI. For instance, a website's static image files will have the request method set to
GET only and disallow the
405 error example
To demonstrate a simple
405 Method Not Allowed example, we can use a curl command within the terminal. This example replicates a sample POST request to a resource that only accepts GET requests, as seen in the image below.
Now if we attempt to pass the HTTP
POST method for the same resource via curl with:
curl -X POST https://www.keycdn.com/img/example.jpg
We receive the response:
<html> <head><title>405 Not Allowed</title></head> <body bgcolor="white"> <center><h1>405 Not Allowed</h1></center> <hr><center>nginx</center> </body> </html>
This demonstrates that the resource will solely allow the
GET method, thus throwing an error for other methods that request the same URL.
How you might see a 405 Method Not Allowed error
This error is primarily displayed as
405 Method Not Allowed. However, there are a couple of other slight variations the web server may display, such as:
- HTTP 405
- Error 405
- (405) Method Not Allowed
- HTTP Error 405 - Method Not Allowed
- HTTP 405 Method Not Allowed
Although the message may slightly differ, they all mean the same thing - the HTTP method used is currently not allowed for the specific web asset being requested from the web server.
Why did I receive a 405 Method Not Allowed error?
405 Method Not Allowed error occurs, it may be due to specific scripts you are trying to run. Some ISPs do not allow particular scripts or the necessary
POST method to be run on their servers, which will return a status code
405. Otherwise, there may be an issue with the web server not being configured properly to accept the appropriate request methods.
Three ways to solve the 405 Method Not Allowed error
Before you start troubleshooting and try the methods described below (especially methods 2 and 3) to fix the problem, we recommend creating a backup of your website. Always ensure you have something to fall back on in case you make a mistake.
The suggested solutions are sorted by degree of effort and the likelihood that this will solve the problem. So work your way through from top to bottom to save time and effort.
1. Check if the URL is correct
The first thing we recommend you do is to check if you have entered the URL of the website you want to visit correctly.
Sounds way too easy, doesn't it? Nevertheless, entering the wrong URL is the most common cause of a
405 Method Not Allowed error. Most web servers are tightly protected and designed to prohibit access to unauthorized URLs to prevent users from visiting the wrong pages.
Speaking of "too simple to be true": Sometimes refreshing the page can also cause it to load correctly.
2. Confirm the configuration of your server
The chances are that your website is running on a server that uses Apache or Nginx. To find out the cause of the
405 Method Not Allowed error, you can check the configuration files of your web server software for unintended handling hints.
First, you need to find out what application your web server is using. For example, provided your web server uses Apache, you should be able to find the .htaccess key file at the root of your website's file system. The Nginx configuration should be found in the
To check the configuration, you can now proceed as follows:
- Find the config file (e.g., .htaccess file in case of Apache)
- Open it in a text editor
- Look for lines that use rewrite paths
- Look for misleading rewrite directives that contain an R=405 response code
- Temporarily comment them out with the # character prefix
- Restart the web server to see if your change fixed the problem
3. Check server side logs
Most web applications keep a server-side log. In it, the complete history of all software activity can be viewed - both from the database results it returns and from the pages it has requested. Server logs thus provide information about the status and state of the server and all connected services.
Connect to your website using Secure File Transfer Protocol (SFTP) to find your server logs. In the root directory, there is a folder called logs. In this folder, you will find your access and error logs (Access.log / Error.log).
From there, perform a similar process as described in the steps before. Look through the logs and look for anything that seems out of place. If you don't want to troubleshoot yourself, ask your developer to do so.
None of the solutions help to fix the 405 Method Not Allowed error?
We hope not, but it is possible the methods described above did not help you fix the
405 Method Not Allowed error. This may indicate that a more complex problem has occurred, and you can only fix it yourself if you are an experienced developer.
In this case, we recommend contacting your hosting provider directly, where you should have access to 24/7 customer support.