Are you experiencing a 405 Method Not Allowed error? Let’s dive into the causes and fixes for this HTTP error.
HTTP errors can be confusing and cryptic, but are important for developers to sort out quickly when they learn users are having issues accessing parts of their web applications. Users have very short attention spans and will take their time (and money) elsewhere if your application starts throwing errors and preventing proper usage.
You should maintain an accessible and easy-to-use contact page on your application, so that users can report bugs and issues. If you are an end-user, trying to access a website, and happen upon this error, you don’t have many options. See the first solution for the only option for an end-user to solve the problem. Beyond that option, contacting the website administrator to let them know about the problem and error code is extremely useful and much appreciated.
HTTP status codes are broken into five main classes, with the first digit identifying the class and the two following digits identifying the specific status code:
- informational (1xx)
- successful (2xx)
- redirection (3xx)
- client errors (4xx)
- server errors (5xx)
There are over 50 status codes that can interact, and parsing out the reason a specific code is thrown is rarely straightforward. Depending on the server your website is using, the HTTP message may vary, but 405 should be clearly stated somewhere in the error. First, let’s take a closer look at what HTTP methods are.
Without being too technical, HTTP (Hypertext Transfer Protocol) works by sending a request to the intended server and then returning a response to the client-side. HTTP methods tell the server what it needs to send or do. The two most common HTTP methods are GET and POST. GET is used to retrieve data from the server without making any changes. When you search for a website or keyword on a website, you are using the GET HTTP method. POST is used to either add or update data, such as stored password or user information. When you create an account on an application, you are taking advantage of the POST Method. Other HTTP methods include HEAD, PUT, DELETE, CONNECT, TRACE, and OPTIONS.
What causes the ‘405 Method Not Allowed’ HTTP error?
These methods are specific enough that if a client attempts to send an incorrect HTTP Method, the ‘405 Method Not Allowed’ error may arise. For example, if a URL is intended to receive the GET method (a simple page with no special scenarios), but the client requests using the POST method, the server may fail to accept that POST request.
Since you are seeing a 405 Method Not Allowed error, this seems to point to a client error. Typically, this client error can be attributed to a content management system (CMS), but there are some server-side problems that can trigger this HTTP error as well.
- Wrong URL used
- Incompatibilities following content management system modifications
- Server Configuration issues
- Source code introduced bugs/errors
How to fix the ‘405 Method Not Allowed’ error
When troubleshooting and making changes to an application or website components, best practice at minimum requires an application backup. Preferably, you will do all updates and work on a secondary offline server for testing and staging. This will prevent any further damage to your original live application, allowing users to continue using the functioning parts of your website. At the same time, you will be able to take your time and test to your heart’s content, to assure all problems are resolved.
Wrong Requested URL
If you are an end-user, the user trying to access the website, then you have one option to solve this problem without getting a website administrator involved. If you have manually entered a specific URL, you may have introduced some errors. Double-check that the URL you are requesting is correct. If you cannot find the link to that section of the website from the main website, chances are, that the URL is not correct. Rarely do website administrators design stand-alone URLs for users to access.
As a website administrator, owner, or developer, if a user contacts you, try to determine the exact URL they are attempting to access. By collecting as much information as possible from the user, you can better understand what went on and the series of factors that might have contributed to the 405 Method Not Allowed HTTP error. If a user is trying to access a private or non-existent URL, you can direct them to the correct URL.
Content Management System Incompatibilities
Content management systems (CMS) are incredibly useful and common on the internet. Allowing new or hobby website administrators an easy way to manage their content. Content management systems handle the majority of the complicated back-end workings, providing administrators with more time to work on their valuable content.
At the same time, content management systems are highly customizable and if you have made changes to any source code, perhaps PHP, updates, themes, or otherwise, problems can arise. The most popular content management systems are WordPress, Drupal, and Joomla.
Revert to Previous version of CMS
If the unintended consequences of some customization have caused the ‘405 Method Not Allowed’ you should always be able to revert changes by rolling back to an earlier update. While most popular CMS are highly stable, you can downgrade to temporarily solve the problem. If you do end up rolling back a CMS update, this should not be a permanent move. The updates are intended to roll out important security and bug updates. Failing to update your CMS for an extended period of time can lead to even more unintended consequences.
- If you are downgrading WordPress, there are quite a few methods available. The easiest method is through a plugin called WP Downgrade. This allows you to avoid manually changing any files. Be sure to back up your site before starting a downgrade!
- If you want to downgrade Drupal, you may have some issues. Drupal’s modules (Composer, for example) can be downgraded, but Drupal core cannot. Before you make any changes to your CMS, it’s important to get in the habit of backing up your application.
- Joomla also does not allow downgrading. Joomla can only be reverted to an earlier update through the use of a back-up.
Uninstall Themes and Plugins
Extensions, themes, and plugins are a way to further customize your CMS and can be a great way to improve your productivity, application, and interface. Plugins and themes are usually created by the community and may be open-source or have an associated fee. Because they are not thoroughly tested by WordPress, Drupal, or Joomla, there can be bugs and incompatibilities.
How to delete a theme in WordPress:
- Navigate to your WordPress admin dashboard, on the left-hand side select Appearance, then Themes.
- Activate another WordPress theme, as you cannot delete a theme that you are currently using.
- Hover over the theme you want to delete and select Theme Details. The Delete button will be in the bottom right-hand corner.
How to delete a theme in Drupal:
Drupal has two main theme designations, core or contributed. The core themes are included when Drupal is first installed and launched. Contributed themes are those you have installed yourself. These should be kept in separate file locations:
- Core: Drupal(root) > Themes > bartik, engines, garland, seven, stark
- Contributed Themes: Drupal (root)> Sites > All > Themes > yourthemes
To delete a specific theme, simply delete the entire directory folder for that theme:
- From the Drupal site you can also navigate to the Manage tab, select Appearance, and then underneath the Installed Themes section find the theme you would like to remove.
- Click Uninstall.
How to delete a theme in Joomla:
- To permanently delete a theme in Joomla, access your Extension Manager.
- Click on the Manage tab on the left-hand side, and check the box for the theme you’d like to remove. On the toolbar above, click Uninstall.
If a theme change was the cause of the ‘405 Method Not Allowed’ error, this should fix the problem.
How to uninstall WordPress plugins:
Plugins are a major component of WordPress and, thankfully, are easy to uninstall if any compatibility problems or bugs arise.
- From the admin dashboard, navigate to the Plugin section and select Installed Plugins. From the list, locate the plugin you want to remove.
- Click Deactivate and when the plugin refreshes, click Delete. Confirm that you want to delete that plugin, and click Yes, Delete These Files.
Check the Database
WordPress is especially susceptible to unintended database changes because of plugins. WordPress has no explicit protections for your database, against problematic plugins. Unless a developer codes the plugin permissions to specifically not edit your database, there is no protection against changes. Deleting the plugin that has edited your database and caused problems will unfortunately not reverse these changes. WordPress cautions inexperienced users from blindly making changes to their database. If you need assistance, you can contact WordPress and an engineer will reach out to assist you.
To access your database on WordPress:
- On your admin dashboard, click My Sites, next find and click Settings, then Hosting Configuration.
- Look for the Open phpMyAdmin button. A new tab will open and if you are not redirected, click the link towards your database.
- Now you will want to check all the entries in your database tables and records. You should be able to see which records and tables were modified by the suspected extension.
Note: If you don’t have experience in managing databases, it’s best to ask for expert help to troubleshoot.
Debug Source Code
This solution will be difficult to work through if you have limited working knowledge of coding. Most major CMS use PHP on the backend. When you are having persistent ‘405 Method Not Allowed’ errors, you may need to manually check the source code of your site or application.
WordPress has a debugging feature that can help you find errors. To enable debugging:
- Use either cPanel or FTP to access your web application’s files. In your root folder, locate wp-config.php and open this file for editing.
- Search for the following code: (‘WP_DEBUG’,false);
- Replace that line with the following code snippet:
// Enable WP_DEBUG mode
define( ‘WP_DEBUG’, true );
// Enable Debug logging to the /wp-content/debug.log file
define( ‘WP_DEBUG_LOG’, true );
// Disable display of errors and warnings
define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( ‘SCRIPT_DEBUG’, true );
- This snippet saves a debug log to your files for you to view at your leisure. Save the file and you can reload your site. Access the same URL or repeat the process that triggered the ‘405 Method Not Allowed’ error. Now you can access your site files again and find a new debug log located at /wp-content/debug.log. With this added information, you should be able to determine the file path and other details on the error source.
Debugging for Joomla or Drupal:
Xdebug is a well-known debugging tool for PHP code. If you are using Joomla or Drupal, it may be best to download Xdebug. Download and setup can be a bit technical, so the following links can help you in that process for each CMS:
Check Server Configuration
Looking at your server configuration can give you insights into the HTTP request handling process. Most likely, your web application or site runs on Apache web server software or NGINX web server software. There are a few other possibilities, such as Node.js and Apache Tomcat.
To check your server’s configuration file:
- Access your root directory, as in previous solutions, using FTP or cPanel.
- Look for one of the following files:
Apache server: .htaccess
NGINX server: nginx.conf
- Click whichever configuration file you find. Now you want to look for directives of either Rewrite rules (Apache) or those using 405 response code flags (NGINX).
- Temporarily comment out those directives can check your website again to see if the error is resolved.
Server configuration files are not easy or simple to understand. If you are having issues and want further explanations or directions, look towards these resources, to get some in-depth information:
405 Method Not Allowed HTTP error resolved
HTTP errors can be difficult to troubleshoot because they can be caused by a myriad of nonspecific causes. Finding the solution may take some trial and error, plus patience. HTTP errors are classed into 5 major categories to help differentiate the status codes. Knowing if the HTTP error is client-side or server-side can give you a better idea of where to start troubleshooting.
The ‘405 Method Not Allowed’ status code points toward a client-side issue, but some server-side solutions have been included to be thorough. Checking the URL should be the first solution when tackling this problem. If any recent changes were made to your web application or site, it’s important to roll those CMS changes back to rule that out as the problem. If using WordPress, the database should be checked because plugins can cause issues. Finally, if the client-side solutions don’t solve the error, move to the server-side solutions. These include checking the server configuration and debugging your source code.
Resolving the ‘405 Method Not Allowed’ HTTP error quickly will return your site to full functionality. This will prevent the loss of users and visitors that are likely to click away from your site when errors like this arise.