Tambena Consulting

What Is 405 Error Code and How To Fix It?

Highlights 

  1. HTTP 405 error occurs when a website rejects the HTTP method used for a request.
  2. Fixes involve checking URLs, rolling back updates, or uninstalling recent plugins or themes.
  3. Server-specific fixes for Apache or NGINX may involve adjusting configuration files.
  4. Debugging involves reviewing code, verifying HTTP methods, and testing locally for errors.

If someone lands on an error page on your site, they might get frustrated and leave. This could cost you valuable engagement and sales. One common error to watch out for is the Method Not Allowed 405 message.

This error can be challenging because it tells you something went wrong but doesn’t explain why. Luckily, with some effort and patience, you can fix it and get your site running smoothly again.

In this post, we’ll break down a 405 error code and how it might appear. Then, we’ll guide you through the steps to fix it on your WordPress site. Let’s discuss it!

What is an HTTP Error 405?

status code 405

A 405 error code is a type of response status that helps explain why a website isn’t responding properly to a request. HTTP response statuses allow users to search the internet with hypertext documents and hyperlinks between websites.

A status code 405 error happens when someone tries to act on a website, such as opening a link or gathering information, but the website doesn’t support the HTTP method used for the request. In simpler terms, the server recognizes the request and confirms the website exists but rejects the method used to access it.

Common variations include:

  • 405 Not Allowed
  • Method Not Allowed
  • HTTP 405 Error
  • HTTP Error 405 – Method Not Allowed
  • HTTP Method Not Allowed 405
  • Error: 405 Method Not Allowed
  • HTTP Status 405 – this URL does not support HTTP method GET

How to Fix the HTTP 405 Method Not Allowed Error?

method not allowed 405

Let’s tackle the “405 Method Not Allowed” error step by step. Here’s how you can troubleshoot and fix it:

1. Double-Check the URL

A mistyped URL is unlikely to cause this error, but checking doesn’t take much time and could save you effort later.

Carefully review the web address for missing letters, typos, or extra characters. Fix any mistakes and reload the page to see if it works. 

2. Undo Recent Updates

Sometimes, a new update to your website causes this error. To fix it, try rolling back recent changes like plugin updates, theme changes, or other modifications.

For example, if you use WordPress, tools like Core Rollback can help you return to an earlier version of your CMS.

Always test your website after each update to avoid issues like this in the future.

3. Check for Database Changes

Unexpected changes in your database might also trigger this error.

  • Check the database’s last update time to spot any recent changes causing the problem. Some extensions might alter your database without reversing those changes, even after uninstalling them.

To inspect your database (for Hostinger users):

  1. Log into hPanel, go to Websites, and select Manage next to your domain.
  2. Under Databases, click Enter phpMyAdmin for your site’s database.

3. In phpMyAdmin, go to the SQL tab and run this query (replace your_database_name with your actual database name):
SQL
SELECT  

    UNIX_TIMESTAMP(MAX(UPDATE_TIME)) AS last_update  

FROM  

    information_schema.tables  

WHERE  

    TABLE_SCHEMA = ‘your_database_name’  

GROUP BY  

    TABLE_SCHEMA;  

4. Look for the last update time and check if any records or tables seem suspicious.

If you find unusual changes, back up your database first. Then, carefully undo those changes to avoid losing data or causing further problems.

4. Uninstall New Plugins, Themes, and Extensions

Installing new themes, plugins, or extensions can sometimes alter your website’s code, resulting in a “405 Method Not Allowed” error.

If the error appears after installing a new plugin or theme, try uninstalling it. Here’s how:

For WordPress Users:

  • Go to the WordPress Admin PanelPlugins and click Deactivate below the most recently added plugins.
  • To delete a theme:
    • Go to AppearanceThemes.
    • Switch to a different theme if you’re using the one you want to delete.
    • Hover over the active theme, click Theme Details, and select the Delete button.

For Hostinger Users (via hPanel):

  1. Go to Websites in the top menu bar.
  2. Select Manage next to your domain name.
  3. From the left sidebar, click WordPressSecurity.
  4. Scroll to Installed Themes or Installed Plugins.
  5. Click the red trash icon next to the items you want to delete.
  6. Confirm the deletion in the popup message.

6. Check Your Web Server Configuration

If the “405 error code” persists, it might stem from web server misconfigurations. The server configuration files control how HTTP requests are handled, and incorrect settings can block certain methods. Here’s how to address this issue for Apache and NGINX servers:

Apache

Apache servers rely on the .htaccess file for directory-specific rules. Common causes of 405 errors include:

  • Mod_rewrite Rules: URL rewriting rules may unintentionally reject specific HTTP methods like POST.
    Example: A RewriteRule configured to handle only GET requests could block POST or PUT requests.
  • Limit Directive: This directive allows restricting methods for certain resources. If configured incorrectly, it might block valid requests.

Steps to Fix:

  1. Access the .htaccess file in your website’s root directory using an FTP client.
  2. Temporarily comment out suspicious rules by adding a # at the beginning of each line.
  3. Reboot the Apache server and check if the issue is resolved.

NGINX

NGINX uses the nginx.conf configuration file, and certain directives can cause 405 errors:

  • Location Blocks: These determine how different HTTP methods are handled. Misconfigured blocks might reject valid requests.
  • Error_page Directive: Improper use of this directive could redirect users to a URL that doesn’t accept specific HTTP methods.

Steps to Fix:

  1. Access the nginx.conf file via SSH using a terminal like PuTTY.
  2. Check for restrictive directives and modify them to allow necessary HTTP methods.
  3. Reboot the NGINX server to apply the changes.

7. Check Your Code and Scripts

How to Fix the HTTP 405 Method Not Allowed Error

The 405 error may result from your application sending unsupported HTTP methods. This is often caused by mismatches between client requests and server-side handling.

Steps to Review and Fix Code:

  1. Verify HTTP Methods: Ensure your code uses the correct method for each action:
    • GET for retrieving data.
    • POST for creating data.
    • PUT or DELETE to update or remove data.
  2. Check for Unsupported Methods: Verify if any libraries or frameworks send unexpected HTTP methods that are not supported by the server.
  3. Debugging:
    • Review custom scripts, paying close attention to how they handle HTTP requests.
    • For WordPress sites, deactivate all plugins and switch to a default theme to isolate potential issues.
    • Identify problematic HTTP requests using browser developer tools.
  4. Test with Unit Testing: Simulate HTTP methods to identify mismatches between the code and server handling during development.
  5. Run a Local Debugging Process: Copy your website to a local development server and replicate the error scenario to narrow down the root cause.

Summary

The 405 error code can be frustrating, but you can usually fix it with some troubleshooting. Start by checking simple things like the URL or recent updates. If the problem persists, look into your database, server settings, or website code. Remember, making backups before making changes is always a good idea. 

Aneeb Ahmad

Aneeb Ahmad

Aneeb is a full-stack SEO & Content Marketer. He drives our inbound marketing efforts on all touchpoints & writes just about everything under the sun! He loves talking about football when he’s not wordsmithing. Email: aneebahmad1@gmail.com

Get A Free Qoute

Please enable JavaScript in your browser to complete this form.