Most Popular WordPress Errors – Common WordPress Errors: Their Causes and Troubleshooting Steps

Most Popular WordPress Errors Their Causes and Troubleshooting Steps - HostNamaste
Most Popular WordPress Errors – Common WordPress Errors: Their Causes and Troubleshooting Steps

Imagine that you want to check your website and instead of its content see that it’s down. It may seem like a disaster but luckily, if you are running WordPress, almost any error you face, was encountered before and there’s a way to fix it by performing the steps that helped many other users.

So here we go with the most common errors and how to fix them:

Database Errors

Error Establishing a Database Connection

Database errors - Error establishing a database connection - HostNamaste
Database errors – Error establishing a database connection – HostNamaste

It’s probably the most popular issue, especially for those who are in the middle of WordPress migration between hosting providers or importing the database to the existing websites. Usually, it’s caused by the mismatch of the database details (database name, user, password, and host). To resolve it, make sure that the details in the WordPress configuration file wp-config.php that are located in the website file directory are corresponding to the ones that are actually on the server.

Here’s how it should look:

1

2

If the hostname is “localhost” it means that the database is hosted on the same account that the WordPress files. The highlighted details should be the same in the SQL settings in your control panel. For most commonly control panel cPanel, they may be found in the MySQL databases menu.

Make sure that the correct user is specified in the “Privileged users” menu like in the screenshot:

3

Scroll down the page to “Current users”, find the correct one and set change password:

4

And copy the password from the wp_config.php file

5

Then go back to the main control panel page, find “PHPMyAdmin” menu that is used to manage databases to check the prefix:

6

If you see a different prefix in the PHPMyAdmin, it’s easier to correct it in the wp-config.php file.

When all the details are correct, the website should be up and running.

A less common issue connected with the database is SQL deadlock. It may occur for large WordPress installations where the code combined with the customized database schema leads to failure of a process because the resources required for its completion are used for other processes. While it’s good for system integrity, it may cause issues with website performance. In order to identify a deadlock query, you may involve a system administrator and examine the SQL logs to find out if the changes to the website code or server configuration are required. You may also find mentions in the general server logs looking similar to the one below:


2021/03/04 10:23:59 [error] 1236789#: * FastCGI sent in stderr: “PHP message: WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT IGNORE INTO


500 Errors

There are 2 types of 500 error: “Internal server error” or “HTTP 500 error”. The second one is usually visible in Google Chrome and appears as a blank page in other browsers.

Internal Server Error

7 e1621915221550

This one is peculiar to the Apache or Litespeed web server. One of the reasons for this error is incorrect permissions (the correct ones are 644 for files and 755 for folders).

8

If permissions are fine, try checking the default file .htaccess. It is responsible for configuration settings and WordPress plugins may add custom rules to it to function properly. Sometimes, these rules conflict with one another, so you may need to turn it off completely by renaming the file to confirm that’s the cause before you go and disable the .htaccess rules one by one.

Pro tip: while renaming .htaccess, make sure to create a blank file, call it “.htaccess” and paste the default WordPress rule:


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


Otherwise, it may cause 404 errors on sub-pages.

HTTP 500 Error

This one is usually caused by a theme, plugin, or lack of php resources specified in the PHP configuration. To find out what’s the case, go to the file directory of your website and locate the file “error_log” and check the timestamps and messages. Usually, it bears the path to the faulty script and line containing the name of the theme or plugin causing the issue.

Here are the examples of such errors:

Theme-related Error


[06-May-2020 08:21:10 EST] PHP Fatal error: Uncaught Error: Call to undefined function greenmart_tbay_get_config() in /home/test/public_html/wp-content/themes/greenmart/header.php:22


To resolve it, you can change the theme, in the PHPMyAdmin panel locating the correct database ( using the name from the wp-config.php, as shown before). Then find the table “options” and then fields called“template” and “stylesheet”.

9

They contain the theme in use that needs to be replaced with a default WordPress theme. It’s easy to find as it’s a year’s name i.e. twentytwentyone. First, confirm that it’s present in your website directory>wp-content> themes.

Plugin-related Error:


[01-May-2021 18:37:32 UTC] PHP Fatal error: Uncaught Error: Class ‘Jetpack_SEO_Utils’ not found in /home/test/public_html/wp-content/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php:3


The changes are done in the same “options” table, in the row “active_plugins”. Open the content and copy it to a text editor to be able to use later. Then, you may either delete the content from the column “option_value” for “active plugin” to disable all the plugins, or just the one from the error, by deleting its value.

1111

E.g. we have something like that:


{i:0;s:37:”async-javascript/async-javascript.php”;i:1;s:27:”autoptimize/autoptimize.php”;i:2;s:36:”contact-form-7/wp-contact-form-7.php”;i:3;s:21:”flamingo/flamingo.php”;i:4;s:19:”jetpack/jetpack.php”;i:5;s:59:”kliken-marketing-for-google/kliken-marketing-for-google.php”}


We will need to delete the highlighted part, and reduce the numbers for the succeeding values by one like this to keep the correct counting:


{i:0;s:37:”async-javascript/async-javascript.php”;i:1;s:27:”autoptimize/autoptimize.php”;i:2;s:36:”contact-form-7/wp-contact-form-7.php”;i:3;s:21:”flamingo/flamingo.php”;i:4;s:59:”kliken-marketing-for-google/kliken-marketing-for-google.php”}


PHP config-related Error


[06-May-2020 08:21:10 EST] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /home/test/public_html/wp-content/plugins/flamingo/functions.php on line 56


To fix this one, you will need to modify php.ini settings paying attention to these parameters: memory_limit, post_max_size, max_input_vars, upload_max_filesize, and max_execution_time. To know the exact PHP values to set, you will need to consult the requirements of your theme and WordPress plugins, or set them to the maximum right away. Here’s an example of how the settings may look like:

11

Also Read: The Ultimate Best WordPress Security Practices for 2021 – HostNamaste

404 on Subpages

The main symptom is when the front website page is opening fine, and Speaking about 404 errors on subpages, the absence of the above mentioned default rule in .htaccess is the first thing to check. Another common fix for 404 on subpages is going to WordPress Admin Dashboard >Settings > Permalinks and switching them to Plain and then back to your custom structure. Here’s what the settings look like:

12

API Errors

When you want to use services like Google Maps, enable credit card payments, or use another integration, the plugins and widgets supporting these services are using API-Gateway to fetch the data from a third-party service to provide it on your website, or vice versa process the information entered on your website to other systems. When this connection cannot be established, you will see API errors. You can see them in error_log as usually, they are self-explanatory. They may occur due to different reasons. Incoming/outgoing requests need to be established with a specific port that is closed by your hosting provider, there are incorrect API Keys or the IP addresses of the external servers need to be whitelisted. The investigation usually starts with going through the system requirements for the service in use, then checking error_log and contacting a hosting provider to clarify if there are any server-related restrictions that prevent using it.

Conclusion

Sometimes, WordPress errors may indeed look scary, but as you can see, most of them can be resolved by following simple steps to identify. And even if you need to address a specific case to a web developer, you will be able to save time for the investigation and speed up the resolution, by providing them with steps you followed and the errors you found to make the work easier.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Reply

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

Enter Captcha Here : *

Reload Image