How to Fix WordPress admin-ajax.php 400 Error?

How to Fix WordPress admin-ajax.php 400 Error?
admin-ajax.php 400

Dealing with the WordPress admin-ajax.php 400 Bad Request error can be both frustrating and unclear. It typically causes features to stop working, like theme functions or forms. Well, fortunately enough, there are simple solutions to fix this issue.

In the following, you will look at how to fix it step by step.

What is the admin-ajax.php 400 Error?

The admin-ajax.php script performs the behind-the-scenes work within WordPress for you. It provides plugins and themes with the ability to push and pull data without page reloading on your site. When you get the 400 Bad Request message, it indicates that the request made by your browser was invalid or broken. 

Causes of the Error

There are some reasons for the error:

  • Browser cache or cookies are messed up.
  • Plugin conflicts
  • Theme problems
  • Server misconfigurations or limitations
  • Security plugins blocking AJAX requests

Now, let's discuss the solutions.

1. Clear Your Browser Cache and Cookies

It is the easiest solution. A faulty cache or an out-of-date cookie can send malicious requests.

How to clear the cache in Chrome:

  • Open Chrome.
  • Press the three dots at the top right side of the screen.
  • Go to More Tools > Clear browsing data.
  • Select the Cached images files and Cookies.
  • Press Clear data.

2. Disable All Plugins

Plugin conflicts are one of the most common culprits for the admin-ajax.php error.

Instructions:

  • Disable All Plugins
  • Plugin conflicts are one of the most common culprits for the admin-ajax.php error.
  • Instructions:
  • Log in to your WordPress dashboard.
  • Plugins > Installed Plugins.
  • Test your site now. Once you GAIN it, update it, change its options, or replace it with a better one.

3. Switch to a Default Theme


Themes sometimes make incorrect calls to admin-ajax.php.

How to test:

  • Go to Appearance > Themes.

  • Activate a default theme like Twenty Twenty-Four.

  • Test your site again.

 Reach out to the theme author for assistance or to switch themes.

4. Check Security Plugin Restrictions

Security plugins like Wordfence or Sucuri may interfere with AJAX requests by mistake.

How to test:

  • Turn off your security plugin temporarily.
  • Check if the error is gone.
  • Identify a setting that filters or blocks AJAX requests and turn it on instead.

5. Increase Server Limits

Your server is perhaps blocking lengthy or complex AJAX requests.

To fix it, increase limits like:

  • PHP memory limit
  • Max input vars
  • Post max size
  • You can do this by editing the php.ini or .htaccess file, or by requesting your hosting provider.
  • Here's a sample you can place in .htaccess
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "WordPress Admin Access Control"
AuthType Basic
<LIMIT GET>
order deny,allow
deny from all
# whitelist Syed's IP address
allow from xx.xx.xx.xxx
# whitelist David's IP address
allow from xx.xx.xx.xxx
</LIMIT>

6. Check Console Errors and Logs

Check your browser's developer tools and look at the Console and Network tabs. They may show the actual AJAX request that's failing.

Alternatively, refer to your WordPress error logs. These typically give useful information on what failed and where.

We’ve also covered fixing the “Site Can’t Be Reached” Error in WordPress — take a look!

Final Thoughts

The admin-ajax.php 400 Bad Request error is infuriating but fixable. Deleting cache, deactivating plug-ins, or theme changes usually work most of the time. Do things step by step. That will enable you to figure out the cause and fix it efficiently. Once your site is live, back it up regularly and use the current plugins.

 

Related Solutions