When trying to sync I receive an error “An index is already occurring. Try again later.” / “WP CLI sync is occurring.”

In general, these error messages indicate that either a sync operation is running without the user’s knowledge, or that a sync operation has gotten “stuck” or failed in such a way that WordPress/ElasticPress considers the indexing to be “in progress.” If you encounter one of these error messages, here are some ways to resolve the issue:

  1. Make sure no indexing operation is running through either WP-CLI or in another browser window/tab. This can happen if you have ElasticPress menus open in multiple browser windows, and an indexing operation is active in one of those windows. In that case, simply allow the operation to complete. This can also occur if you close a browser window mid-sync. If you suspect this has occurred, opening the ElasticPress Sync page in the WordPress Dashboard will show the paused sync, which can then be canceled or resumed.
  2. If you have confirmed that no sync is running, or are unable to find the in-process sync, you can manually clear the data associated with the ElasticPress sync process by issuing the following WP-CLI command: wp elasticpress clear-sync
  3. You can also start a new sync using the --force flag. It will clear the data associated with the ElasticPress sync and start a new one in a single command: wp elasticpress sync --force.

In sites using ElasticPress versions prior to 4.0 it is needed to run the following WP-CLI command (be sure to copy the entire command):

wp eval 'delete_transient( "ep_wpcli_sync" ); delete_option( "ep_index_meta" ); delete_site_transient( "ep_wpcli_sync" ); delete_site_option( "ep_index_meta" );'