Diagnose High Admin-Ajax Usage

Diagnosing high admin-ajax.php usage is a widespread scenario when dealing with WordPress or WooCommerce.

The admin-ajax.php file is used by both Conj - eCommerce WordPress Theme and companion plugin (CONJ PowerPack), as well as many other plugins, to perform common actions in your shop, such as applying a discount code, validating the checkout, completing a purchase.

Use the suggestions below to help track down the problem and get it resolved and note that the error is generally caused by 3rd party plugins or from frequent un-cachable admin dashboard requests, due to the Heartbeat API, such as autosaving drafts.

It is important though that you diagnose high admin-ajax.php spikes when you see them, as they have been known to bring a site to a crawl.

Plugin Conflicts

Some plugins are known to block access to admin-ajax.php intentionally. The following types of the plugin are often responsible:

  • Security plugins — these plugins often have a setting that disables admin-ajax.php, or a similar setting for blocking access to admin files.

  • Plugins that disable /wp-admin/ access for non-administrators.

  • Minification plugins — Minification plugins. These plugins do the performance improvements by shrinking the size of javascript (and other) files and this process often breaks the javascript files within the Conj - eCommerce WordPress Theme that is responsible for communicating with admin-ajax.php file properly.

  • Caching plugins — Occasionally caching plugins can cause problems with admin-ajax.php by either breaking the javascript that creates the ajax requests or by simply making admin-ajax.php file inaccessible.

If Ajax is not working on your site properly and you have any plugin that matches the descriptions above, try deactivating the plugins and then testing to see if admin-ajax.php becomes accessible again. If it does, then you may still be able to use the plugin, you will just need to find the problematic setting in the plugin and disable it.

Hosting Privacy and Maintenance Modes

Some hosts like Pantheon and Flywheel have this Privacy or Maintenance mode settings that allow you to prevent access from visitors without a password or other access. In some cases, this can prevent the Conj - eCommerce WordPress Theme from communicating properly with Ajax.

Firewalls

Occasionally, service provider (hosting) companies will set up a firewall on your site that is intended to protect your site, but that also has the adverse effect of blocking access to admin-ajax.php.

If you are having trouble with ajax, check if your host has a firewall and ask them to disable it temporary. If Ajax begins working after disabling the firewall, you have found the culprit. If Ajax is still inaccessible after disabling the firewall, you can safely re-activate it.

Rules in Your .htaccess File

The .htaccess file used on Apache servers can sometimes include special rules that are designed to protect your site from attacks. Some times these rules are applied little generic and unintentionally disable access to admin-ajax.php.

If your ajax is not working, check to see what rules your .htaccess file contain. If there are any rules beyond those shown below, remove them and see if ajax begins working again.

Your .htaccess file will usually contain rules that look like below:

.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

NGINX Configuration

Sometimes the admin-ajax.php file is inaccessible due to misconfiguration of the NGINX environment.

You could ask your service provider support to add the following line to the nginx.conf file:

add_header ‘Access-Control-Allow-Origin' ‘*';

Cross Domain Issues

The admin-ajax.php file must be run on the same domain from which it's called.

As an example in case your site is https://www.example.com and you try to call https://example.com/wp-admin/admin-ajax.php it won't work as expected.

Note the www in the first URL, and NO www within the second address.

This is also true with an SSL mismatch in web address.

As an example in case your site is https://www.example.com and you try to call http://www.example.com/wp-admin/admin-ajax.php it won't work as expected.

Note the https in the first URL, and NO https within the second address.

As mentioned above there are some quick and easy options to both diagnose and resolve admin-ajax.php issues. Typically they arise from 3rd party plugins that might be conflicting with one another or are perhaps badly coded.

If you are experiencing CPU load on the back-end as a result of admin-ajax.php, you might also want to consider a managed WordPress host who is more experienced in dealing with these types of performance issues.