How to Solve the Most Common WordPress Errors

how to solve the most common wordpress errors

Today we are going to explain and give you some instructions on how can you fix the most common WordPress errors that may occur on your WordPress website.

There is no strict rule to fix the issues since we need to debug first and understand what the problem may be, but sometimes some errors are very common and there are quick fixes, that all WordPress users need to know.

solving the most common errors in wordpress

Fixing the issues will be explained with real examples on the server, with preinstalled WordPress website. These issues are server-related issues and may be very useful for the users that are maintaining their WordPress on their own. Let’s get started!

Prerequisites

  • Fresh install of WordPress on Ubuntu, CentOS or Debian as OS
  • User privileges: root or non-root user with sudo privileges

1. Missing .htaccess file

The “.htaccess” file by default is not created after the new installation of WordPress. The .htaccess file is a configuration file for storing rules that control your web servers like redirects, password protection, permalinks and etc. This file is created after setting up the permalinks through the WordPress admin dashboard. If the .htaccess file is not created after setting up the permalinks, we will show you how it can be created manually:

First, go into the document root of your WordPress website:

cd /var/www/html/

Using your favorite editor create the file:

nano .htaccess

Paste the following lines of code:

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Save the file, and close it.

The “.htaccess” code can be found at the official WordPress site.

2. 403 Forbidden access

how to fix common errors in wordpress

The 403 Forbidden access means that the request is accepted by the server, but the server refuses to authorize it. The reason for this can be incorrect file or folder permissions, corrupted .htaccess file, or some plugin. To be sure about the file and folder permissions, you can set them to the correct one with the following commands:

First, be sure that you are in the document root of your website

cd /var/www/html/

chown -R www-data:www-data .

find . -type d -exec chmod 755 {} \;

find . -type f -exec chmod 644 {} \;

The folders are with 755 and the files are with 644, while both are owned by the “www-data” user and group.

If the .htaccess is corrupted then it is a good practice to recreate it or to restore it from the backup on the server or if you have it locally.

The problem with plugins can easily be solved, by deactivating the plugins temporarily. To deactivate the plugins follow the steps below:

Enter in the WordPress plugins directory

cd /var/www/html/wp-content

Rename the plugins directory

mv plugins plugins.backup

Refresh the page and access your admin dashboard. Once everything is OK, go back on your server and revert the name from plugins.backup to plugins again. Enable the plugins one by one and see which one is the culprit.

3. Error Establishing a Database Connection

fixing common errors in wordpress

This issue is related to the database itself, which may be caused by multiple reasons, like MySQL service, wrong database credentials in the WordPress configuration file, corrupted database tables, and etc.

MySQL service: Check if the MySQL service is up and running on your server with the following command:

systemctl status mysql

If the service is stopped, you should see the following output:

root@vps:/var/www/html# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2021-12-01 15:31:21 UTC; 5min ago
    Process: 40051 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 40051 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete"

Start the service with the command below:

systemctl start mysql

When MySQL service is up and running you should receive the following output for status

root@vps:/var/www/html# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-12-01 15:38:50 UTC; 1s ago
    Process: 40808 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 40822 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4617)
     Memory: 360.1M
     CGroup: /system.slice/mysql.service
             └─40822 /usr/sbin/mysqld

Wrong Database Credentials: You need to open the wp-config.php file located in the document root of your WordPress website and pay attention to the entries shown below:

define( 'DB_NAME', 'wpdb' );

/** MySQL database username */
define( 'DB_USER', 'wpdb' );

/** MySQL database password */
define( 'DB_PASSWORD', 'Your-Strong-Database-User-Password' );

If the credentials are not correct please make sure to correct them and try to access the website again.

Corrupted database: This issue is related to the database tables and in order to check and fix them, you need to use the following commands with WordPress database user and password:

root@vps:~# mysqlcheck -c wpdb -u wpdb -p 
Enter password:

If everything is OK, then you should receive the following output:

wpdb.wp_commentmeta                                OK
wpdb.wp_comments                                   OK
wpdb.wp_links                                      OK
wpdb.wp_options                                    OK
wpdb.wp_postmeta                                   OK
wpdb.wp_posts                                      OK
wpdb.wp_term_relationships                         OK
wpdb.wp_term_taxonomy                              OK
wpdb.wp_termmeta                                   OK
wpdb.wp_terms                                      OK
wpdb.wp_usermeta                                   OK
wpdb.wp_users                                      OK

To optimize the database you can use the commands below:

root@vps:~#  mysqlcheck -o wpdb -u wpdb -p
Enter password:

4. There has been a critical error on this website.

how to fix daily errors in wordpress

In this case, we do not know, what is the issue because by default the debug mode is not enabled in the WordPress configuration file. To enable the debug mode go to the document root of your WordPress website and open the wp-config.php file

cd /var/www/html && nano wp-config.php

Search the word “WP_DEBUG“, and set it to true.

 define( 'WP_DEBUG', true );

Once, the debug is set to true, save the file, close it, and refresh the website

fixing daily errors in wordpress

Now, you can notice that when debug mode is set to true, we can see the exact error. In this case, it is some kind of syntax error on line 616 in the file at /var/www/html/wp-content/themes/twentytwentyone/functions.php

Once, the issue is fixed in the code of the theme you can revert the debug mode to false and refresh the page.

5. 404 Error

fix wordpress errors easy

This is one of many WordPress common errors you might see. This error means that the client was able to connect to the host, but the requested resource on the server is not returned or is not found. This error is related to the WordPress site permalinks and as we described a couple of steps above that the permalinks are stored in the .htaccess file. It is a good practice if you have .htaccess from backup to compare the content of it.

6. Connection Timed Out Error

This common issue may be related to the server resources. Your WordPress website is trying to load but after some time it gives up and that is why you are getting this message. The possible solution may be to optimize your WordPress by removing some unnecessary plugins, increasing the PHP memory limit, optimizing your web server, or upgrading to a higher hosting plan.

7. White screen of Death

One of the hardest issues to debug is the white screen of death. There are no messages, as on the issues described above, and that is why we are going to provide you with some useful steps, on how to start to debug this issue.

1. Activate the Debug mode to true: Try to activate the debug mode in the wp-config.php file and try to refresh the page to see if some errors will appear on the website. If the screen is still white proceed with the next suggestion.

2. Memory Limit: Increase the memory limit in the php.ini configuration file.

3. Disable the plugins: If increasing the memory limit does not help, disable the plugins as is described in the second common issue about “403 Forbidden access”. Refresh the page again and if the website is loaded then try to enable the plugins one by one and that way you will detect which one is the culprit.

4. Disable the theme: If disabling the plugins does not help, log in to your server and disable your active theme. If the screen is still white then you need to contact your hosting provider in order for them to see what is the issue with your WordPress.

That’s it. We tried to explain the most common WordPress errors that may occur on every client’s server and the possible solutions. Of course, if you find it difficult to manage your WordPress website and solve the issues that may appear, we are always here to help you. If you use one of our WordPress hosting plans our admins will help you to solve every possible issue. Do not hesitate to contact us anytime you want. We are available 24/7.

P.S. If you liked this post on How to Solve the Most Common WordPress Errors please share it with your friends on the social networks by using the share shortcuts below, or simply leave a comment in the comments section. Thanks.

Leave a Comment