Back

WordPress Tutorial: Quick Fix for REST API, Loopback Request & Site PHP Fatal Error

[featured-image]

Did you encounter any of the following errors?

  1. The REST API encountered an unexpected result
  2. Your site could not complete a loopback request
  3. Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.

After rounds of investigation, here are some of the possible quick fix solutions to these issue:

Solution 1: Deactivate ALL Plugins and Reactivate One by One

This is one of the most common solution I saw in different community. Theme and plugin crash is a very common WordPress issue to most people. By deactivating ALL your plugins and turn them on one by one, you are able to debug and see which plugin may potentially cause the errors.

If you are highly concerned that your site may breakdown with such great change, I would recommend you to set up a staging site to test. Then you will not affect your live site while you can also test which changes may lead to those errors.

Solution 2: Revise Code in /wp-admin/includes/file.php

This method is for resolving the update issue with php file – “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

Solution:

  1. Go to cPanel > wp-admin > includes > Edit file.php
  2. Search for the code ” if ( $is_active && ‘php’ === $extension ) {
  3. Replace it with ” if ( $is_active && ‘php’ === $extension && false){

This method works perfectly for me but some people are saying that this method is not ideal as the entire statement will return false and will be reverted once you update new version of WordPress. I am not sure the consequence of this as I am not developer. So, be cautious for this act and always remember to save a copy before you made any change to server files! And if you make any coding changes, I would recommend you to keep a changelog file, so that you can debug and track the changes easier.



Solution 3: Download WP Editor Plugin

This solution can help to resolve the “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.” error as well. Your Theme Editor interface will downgrade back to previous WordPress editor interface and the update file function would work perfectly.

Solution:

  1. Download and Activate “WP Editor” Plugin
  2. Go to Appearance > Theme Editor > go to function.php and click “Update File”, you should be able to save the php file now

The original tutorial I saw has mentioned that you can delete the plugin afterwards. I tried and the error will occur again. This may be a safer solution with no cPanel edit required but one drawback is that the plugin is not frequently updated which may not be able to support newer WordPress version in the future.



Solution 4: Go to Edit PHP file in cPanel Directly

This is another technical option as you will also login to cPanel to edit the files. You can bypass the WordPress check for fatal errors and update the php file content directly. I try and it works perfectly, just that it is not very convienent.

Solution:

  1. Access to cPanel > wp-admin > Themes > (Your Theme Name) > Edit the php file > Save the file
  2. Go back to WordPress Dashboard > Appearance > Theme Editor, you should able to see the change in WordPress after you have saved the changes in the local file

Ultimate Solution: Revise Cloudflare Bot Fight Setting

I found this accidently after researching online. If you have implemented Cloudflare in your site and encountered the 3 errors mentioned above. This may be the solution to your case!

Solution:

Access to Cloudflare > Select your site > Security > Bots > Disable “Bot Fight Mode”

By doing so:

  1. Go back to your WordPress Dashboard > Tools > Site Health, you should see the 2 errors – “The REST API encountered an unexpected result.” and “Your site could not complete a loopback request” are now disappeared.
  2. Go to Appearance > Theme Editor > go to function.php and click “Update File”, you should be able to save the php file now.

Hope this helps! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *