WordPress Heartbeat API: How to Limit or Disable It Safely

WordPress’s Heartbeat API is a small script that keeps your browser talking to the server while you are logged in. It powers post autosave, the lock that stops two people editing the same post, and the “you have been logged out” prompt. It does this by sending a request to admin-ajax.php on a timer, and […]

WordPress Heartbeat API: How to Limit or Disable It Safely

WordPress’s Heartbeat API is a small script that keeps your browser talking to the server while you are logged in. It powers post autosave, the lock that stops two people editing the same post, and the “you have been logged out” prompt. It does this by sending a request to admin-ajax.php on a timer, and on a busy or underpowered server those requests can add up, especially if you leave several admin tabs open. This guide explains what Heartbeat does, how to tell whether it is actually a problem on your site, and how to slow it down or switch it off safely.

How often Heartbeat runs

By default Heartbeat sends a request every 15 seconds while you are editing a post, and every 60 seconds on other admin screens. When the tab is in the background, browsers and WordPress slow it right down. It also runs on the front end for logged-in users if a theme or plugin asks for it, but most sites do not use it there.

For a single editor on decent hosting, that is nothing to worry about. It becomes a problem on cheap shared hosting with a low limit on PHP processes, when several people leave the editor open all day, or when a plugin hooks extra work into each Heartbeat tick. The usual symptoms are high CPU usage warnings from your host, slow admin pages, or lots of admin-ajax.php requests in your server logs.

Check before you change anything

Do not disable Heartbeat just because a speed test lists admin-ajax.php. Visitors who are not logged in rarely trigger it, so it seldom affects what Google or your readers see. To check properly:

  1. Open your browser’s developer tools (F12), go to the Network tab and filter by admin-ajax.
  2. Leave a post open in the editor for a couple of minutes and watch how often requests appear and how long each one takes.
  3. If each request takes well under a second and your host is not complaining, leave it alone. If they are slow or your host’s resource graphs spike with the editor open, carry on.

Option 1: Slow it down with a plugin (recommended)

The safest fix is to keep Heartbeat but make it run less often. The free Heartbeat Control plugin lets you set separate rules for the dashboard, the post editor and the front end. A sensible setup is:

  • Post editor: modify to 60 seconds, so autosave and post locking still work.
  • Dashboard: modify to 120 seconds, or disable if nobody relies on dashboard widgets that update live.
  • Front end: disable, unless a plugin such as a live chat or membership tool needs it.

If you already use a performance plugin, check its settings before installing another one. WP Rocket, LiteSpeed Cache and Perfmatters all include Heartbeat controls, and running two tools that change the same thing is asking for trouble.

Option 2: Change the interval with code

If you would rather not add a plugin, the heartbeat_settings filter sets the interval in seconds. WordPress accepts values from 15 to 120:

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

Option 3: Disable it everywhere except the editor

This is the best middle ground if you are the only person who edits the site. Heartbeat is removed from the dashboard and front end but kept on the post editing screens, so you do not lose autosave:

add_action( 'init', function () {
    global $pagenow;
    if ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow ) {
        wp_deregister_script( 'heartbeat' );
    }
}, 1 );

To switch it off completely, remove the if check and keep only the wp_deregister_script( 'heartbeat' ); line. Be aware that you then lose autosave, post locking and the session expiry warning, so a browser crash or a second editor can cost you work.

Where to put the code

Avoid pasting snippets straight into your theme’s functions.php through the built-in editor. A typo there can take the whole site down, and a theme update wipes the change. Better options, in order:

  1. A code snippets plugin such as Code Snippets or WPCode. They catch fatal errors, let you switch a snippet on and off, and survive theme changes.
  2. A small custom plugin: a single PHP file in wp-content/plugins with a plugin header. This is what we use on TGH for site-specific tweaks.
  3. A child theme’s functions.php, if you already have a child theme.

If you do use the built-in editor, it is now at Tools > Theme File Editor on block themes and Appearance > Theme File Editor on classic themes. Take a backup first and have FTP or your host’s file manager ready so you can undo a mistake.

Other admin-ajax culprits

If you have tamed Heartbeat and still see heavy admin-ajax.php traffic, the cause is usually a plugin: page builders, statistics plugins, social share counters and some security plugins all use it. Deactivate plugins one at a time and watch the Network tab. While you are tuning performance, our guides to removing query strings from static assets and using Cloudflare to block spam bots cover two more easy wins.

FAQ

Will disabling Heartbeat speed up my site for visitors?
Usually not noticeably. It mainly affects logged-in users. The benefit is lower server load, which can help indirectly on small hosting plans.

Is it safe to disable Heartbeat?
Slowing it down is safe. Disabling it in the editor removes autosave and post locking, which matters if several people edit content.

Does WooCommerce need Heartbeat?
Parts of the WooCommerce admin use it, so on a shop keep it running in the dashboard and editor and only reduce the frequency.

🛠️

Gear We Recommend

A few general tech accessories worth having alongside this.

Browse our General Tech Accessories picks on Amazon

As an Amazon Associate, TechyGeeksHome earns from qualifying purchases.


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Intune, Active Directory, PowerShell and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published 770+ practical guides to real-world IT problems. He also builds free Windows utilities, including Ultimate Settings Panel, which has been downloaded over 850,000 times.

3 thoughts on “WordPress Heartbeat API: How to Limit or Disable It Safely”

  1. Can the heartbeat control plugin be used in any way to speed up the wordpress dashboard? IF so, what what you recommend for a rule?

  2. Can the heartbeat control plugin be used in any way to speed up the wordpress dashboard? IF so, what what you recommend for a rule?

  3. Can the heartbeat control plugin be used in any way to speed up the wordpress dashboard? IF so, what what you recommend for a rule?

Comments are closed.