How to Fix Typical WordPress Errors?


While running a WordPress site, we will run into issues and errors. A backup & restore may not resolve your issue, and a plugin may not display itself as the source of your problem, at least not immediately. It's hard to tell what is causing your site issues. Here, will cover the basics of troubleshooting with your WordPress installation. The first place you need to look for the source of your problem is within the error log.


Where Can I Find WordPress Error Logs?


The most common seen error log used within WordPress investigations does not arise from WordPress but somewhat from your PHP installation on the server. The php.ini file control PHP settings for your site and determine if and where the error log is reaching. If this is permitted, you can usually find the error log in your WordPress installation's directory. In most cases, this file is titled error_log but is clinging on the setting in the php.ini file. You can also get the WordPress PHP error log (if enabled) within the wp-content folder in a PHP.error_log file. If you don't find from the ways mentioned above, you need to enable debugging or PHP logging in your php.ini.


How Do I Enable WordPress Debugging?


You can facilitate debugging for WordPress within the wp-config.php file. It is necessary when trying to discover why a site is no longer loading or is erroring. We can't ever conclude without seeing the errors created. To better see what is occurring, just edit the following line within your wp-config.php file:

define('WP_DEBUG', false);


And change the false to true:

define('WP_DEBUG', true);


Changing the value to true will enable the debug mode and display any site code errors directly on the page. It can be helpful when tracking down site problems or seeing if upgrades have created any new issues.


Modifying PHP Versions


If you modify PHP versions and the site no longer loads. The wp-config.php is also where you can enable the WordPress PHP error log and log directly to a file rather than printing to the screen. You can do this by adding the following code to the wp-config file:

define('WP_DEBUG_LOG', true);


This code provides the WordPress PHP error log (PHP.error_log) if errors are present and generated. You can find this file within the wp-content folder of your WordPress installation. 


Enable PHP Error Logging

If you would instead enable PHP error logging you can add values to the php.ini for the domain or via the .htaccess file if your configuration supports them:

Open your site’s php.ini file. If you are unsure where this is located, you can use a phpinfo page to show the location or you can also run the following in command line:

cpUser=`pwd | cut -d/ -f3`; for i in `pwd`; do touch $i/phpinfo.php; chown $cpUser. $i/phpinfo.php ; echo "<?php phpinfo(); ?>" > $i/phpinfo.php; done


Create PHP Info Page

Manually create a phpinfo.php file within your website's public_html folder, utilizing the following code.


After appending this code to the file, access this file via a browser at the location, you created it. You will find the php.ini path under Loaded Configuration File:


Once you find this location, edit the file and add the following code if it does not exist:

;;; log php errors
 display_startup_errors = false
 display_errors = false
 html_errors = false
 log_errors = true
 track_errors = true
 error_log = /home/USER/logs/error_log
 error_reporting = E_ALL | E_STRICT

 error_reporting = E_ALL | E_STRICT


You can change the path for error_log to wherever you want this to store within your user's home directory. The WordPress install is attached to the same access rights as the user installing it not to have the permissions to write outside their home directory.


On older setups you can change the logging information via .htaccess if your configuration supports php_flags (using DSO aka as Data Source Object)

# log php errors
 php_flag display_startup_errors off
 php_flag display_errors off
 php_flag html_errors off
 php_flag  log_errors on
 php_value error_log /home/path/logs/error_log


Most likely newer and up-to-date configurations are not using DSO, and you will need to modify this via the php.ini file.


How to Read Error Logs


To understand how to read the output of these logs looks at the following entry:


[09-Sep-2018 22:57:20 UTC] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 32768 bytes) in home/USERNAME/public_html/wp-content/plugins/wordpress-seo/inc/class-wpseo-meta.php on line 477


You can see the date and time stamp followed by the general message and path this stems. It tells you most of the details you will need to determine where the problem lies. The path will usually show a plugin or theme and the software's location, generating the error. Display the line in the document or file that triggered your website's developer's error can further review.


What Are Some Common WordPress Errors?


Fatal Error

The "fatal error" is the most common type of error seen and the cause can vary from coding, like "undefined function", mean the function and problematic line of code to memory errors (like the one used in the above example). Usually, the server runs out of memory, or the PHP memory limit is not set high enough to run the code's requirements. To fix these errors, you may need to update software (themes and plugins usually). You may also need to increase the PHP memory limit or locate any heavy resource usage on the server that may be consuming memory.


Error Establishing a Database Connection

Generally means there is an issue with the database in use or the configuration of your WordPress setup. It indicates your database is corrupt or the configuration settings used in your wp-config are not correct or modified. Check your wp-config file has the proper credentials and syntax to ensure your database can communicate with your WordPress files. You may also see this error when the server is under a heavy load, or the MySQL service is down. 


File Not Found

A conventional 404 error indicates your server could not locate the file called by the software in use on the domain. Usually, when ownership or permissions are wrong, the file path is called wrongly, or the file is lacking.



WordPress can sometimes run for a while without issue, but some common errors can be solved with a little background. As always, our helpful support experts are here to assist with any WordPress related errors.  


Was this answer helpful? 0 Users Found This Useful (0 Votes)