Skip to content
01

admin-ajax.php 500 error in WordPress: how to diagnose and fix it

An admin-ajax.php request returning a 500 error always hides a specific PHP error. Here is how to read it, find the plugin responsible and fix it for good.

Walid Sadfi
5-minute read
Share:

A button that spins forever, a WooCommerce cart that no longer updates, an Elementor editor that refuses to save: in the browser console, you often find the same line, a POST request to /wp-admin/admin-ajax.php answering with a 500. That code only tells you one thing: PHP crashed while handling the request. The good news is that the exact cause is almost always written down somewhere. You just need to know where to read it.

What admin-ajax.php does

admin-ajax.php is the historical AJAX entry point of WordPress. Plugins and themes send requests to it with an action parameter, and WordPress runs the function hooked to that action name. The file itself is rarely the problem: the error comes from the function called behind it, so from a plugin, the theme or a server limit.

Step 1: read the real error message

Do not deactivate anything at random before reading the error. Turn on the WordPress debug log by adding these lines to wp-config.php, above the line telling you to stop editing:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Reproduce the problem, then open wp-content/debug.log. The last Fatal error line gives the file and the line that crashed. If the file stays empty, check your host's PHP error log, and in the browser developer tools, the Network tab then the response of the admin-ajax.php request: it sometimes contains the full message.

Step 2: identify the action and the plugin

In the Network tab, click the failing request and look at its payload: the action parameter often carries the plugin prefix, such as woocommerce_, elementor_ or wpforms_. Combined with the file path in the log, you know who is responsible without deactivating the whole site.

The most common causes and how to fix them

A fatal error in a plugin

This is the most common case, often after a PHP upgrade: an old plugin calls a function removed in PHP 8. Update the plugin, or test the previous version. To check without affecting visitors, the Health Check & Troubleshooting plugin deactivates plugins for your session only. With command-line access, WP-CLI lets you isolate the culprit on a staging copy:

wp plugin list --status=active
wp plugin deactivate plugin-name
wp plugin activate plugin-name

PHP memory exhausted

The log shows Allowed memory size exhausted. admin-ajax.php requests go through the admin area, which uses its own limit. Raise both in wp-config.php, within what your host allows:

define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

If memory climbs back up a few weeks later, the real problem is elsewhere: a query loading too much data or a badly written loop. Raising the limit only buys time.

Execution time exceeded

An AJAX action calling a slow external service or processing a large import can exceed max_execution_time. The lasting fix is to split the processing into batches, or to set a maximum timeout on external calls so that a third-party service going down does not block your site.

Heartbeat overloading the server

The Heartbeat API sends an admin-ajax.php request every 15 to 60 seconds from each open admin tab. On modest hosting, a few logged-in editors are enough to cause intermittent 500 errors. Spacing out these requests relieves the server without breaking anything:

add_filter( 'heartbeat_settings', function ( $settings ) {
    $settings['interval'] = 60;
    return $settings;
} );

500, 400 or 403: do not confuse them

  • A 400 error with a 0 response means that no plugin registers the action: a deactivated plugin or a badly written hook.
  • A 403 error usually comes from a firewall or an expired security token (nonce), not from PHP.
  • A 500 error means PHP crashed: the answer is in the logs.

Keeping the error from coming back

Test plugin and PHP updates on a staging copy before production, keep an error log active, and monitor slow admin-ajax.php requests. Set WP_DEBUG back to false once the problem is solved. If you would rather delegate, our WordPress maintenance service monitors these errors and steps in before your visitors see them.

Frequently asked questions

Can admin-ajax.php be deleted or blocked?

No. Many plugins, WooCommerce first among them, depend on it. Blocking it breaks site features, often without a clear message.

The error only appears for logged-out visitors, why?

Public actions go through the wp_ajax_nopriv_ hook. If only that hook fails, it is often a page cache serving an expired security token, or a plugin assuming a logged-in user.

Need a developer to fix the problem or keep it from coming back? Discover our WordPress maintenance service.

Author

Walid Sadfi

Walid Sadfi is the founder of Evolurise, a team of engineers deployed on site with its clients: custom development (WordPress, Drupal, React, Laravel), AI agents, DevOps and team training. With 8 years of experience, he supports SMEs and large companies, from understanding the problem to deploying the solution. On this blog he shares practical, field-tested insights.