Search the site:

Copyright 2010 - 2018 @ DevriX - All rights reserved.

Fixing WordPress Errors? It’s Easy If You Do It Smartly

Fixing WordPress Errors

Developing a modern WordPress website can be troublesome if you haven’t used the platform before. The WP ecosystem is constantly on the rise and evolves so fast that sometimes, it’s hard to catch up with all the platform problems and their solutions.

WordPress is the best content management system. It easy to use, extremely powerful and you can create everything, from a blog to a magazine and e-commerce platforms.

According to W3Techs, “WordPress is used by 60.3% of all the websites whose content management system we know. This is 30.2% of all websites.” This includes some of the biggest brands in the world, such as TechCrunch, MTV, Microsoft, and Vogue.

But, even the developers that have set up and developed the websites above, had to come across on an error or two when maintaining the websites. There are reasons that these errors happen and they need to be fixed immediately.

With this article, we hope to give you insight into the most common WordPress problems that may occur when developing your website. We’re going to talk about smart solutions for those problems and the tools that you can use to solve them. With this in mind, we hope to help you cope better with WP errors and keep up with the latest WordPress solutions. Now, let’s dive in!

The First Problem: Blank White Screen

When you try to open a WP website, there’s nothing worse than looking at this:

white-screen-of-death

Seeing the above makes your WordPress website unreachable to admins and users. This can bring additional problems to your website too. Let’s have a look at what causes this problem first.

Causes

Developers know that the so-called “White screen of death” in 90 percent of the cases is caused by either an error in PHP coding or it’s a case of memory exhaustion. The main thing that you need to check here is whether you can access the admin panel on your WP website, often called the WP admin or WP panel. In most cases, you can access by entering:

https://yourdomain.com/wp-admin

If everything is fine, you will be redirected to a WordPress login page:

wordpress login page

If not, a different blank white screen may appear on your browser, for example, if you use Chrome the screen will give you an alert in the form of HTTP 500 Error.

500 chrome

Now, what can you do to solve this problem? First things first, you will need to check whether you’ve written a bad line of code on your WP website intentionally or unintentionally. Only one mistyped character can bring down your entire website!

SFTP client

If you can’t access your admin panel, you can always connect to a Secure File Transfer Protocol (SFTP) and manually retrogress the bad code. STFP is used for file transfers as a much more secure option to a standard FTP.

To connect to an SFTP, you will need an SFTP client first. There are many that you can download free or buy a premium package:

When you open the SFTP client, you will need to access the following settings:

  • Connection type: SFTP (not regular FTP)
  • Address/URL/Hostname: Use your IPv4 Address.
  • Username
  • Password
  • Port

Web hosting providers should already give you the information that is listed above.

Debugging

Another solution to the “White screen of death” is to dig a little deeper into your WordPress code and run a debugging process that will uncover any errors in your PHP code.

To run a debugging process for your WP website, you will have to access the wp-config.php File within your WordPress installation files. There, you should find the following:

Try to replace false with true, and refresh your website. Now, instead of the white screen, you should see a screen with error messages in your browser. In most cases, the errors are marked with the exact line, for example:

Cannot get_posts()in /var/www/html/wordpress/wp-content/plugins/my-test-plugin/my-plugin.php on line 67

If you know how to change your code, you can solve the problem by yourself. If it’s a plugin issue and you don’t know how to deal with it, it’s often best to contact the plugin developers and ask for their support.

If the plugin troubleshooting can’t fix the problem, perhaps the problem lies in the theme’s code. You might even see a message like this on your white screen:

Parse error: syntax error, unexpected $end in /home/name/public_html/wordpress/wp-content/themes/your_theme/functions.php on line XXX

WordPress can’t function properly if its code is broken, so, you’ll have to revisit the theme files and modify them so that they are exactly the same as before the blank white screen appeared. Use FTP client to upload a working version of the functions.php file or use a child theme to add changes to your theme without losing the original code.

Memory Limitation

If the above doesn’t fix the white blank screen the next possible cause is – memory exhaustion. In most cases, this can be solved by accessing the wp.config.php file of your WP install and adding the following code:

You can also use the .htacess file, located in the WP root directory, by adding the following:

php_value memory_limit 128M

Or, you can do that from the php.ini which bump the limits across all installs on the server in general.

The wp-config.php sets the memory limit for each WordPress site which has the php.ini file. This can affect your whole server. The php.ini is the parent setting, and so you can set up WP to whatever you want within php.ini’s range.

It’s also important to note there is a WP_MAX_MEMORY_LIMIT where you can define the max amount of memory WP should use, especially if you have plugins gobbling up all the memory.

Next Up: Internal Server Error

Again, this is an error that users and developers encounter frequently with their WordPress websites. An Internal Server Error occurs when there’s a problem with the server that is hosting your WP website. In most cases, the cause can be found in the root directory or in your host’s server.

This error is frustrating because it doesn’t show you exactly how to solve the problem. But, fortunately for you, we can show you how to handle this.

Create New .htaccess File

Open your WP root directory in FileZilla or whichever FTP client that you prefer to use. Open the public_html folder where you can find the wp-admin and wp-content folders. Somewhere in those two folders, your .htaccess file resides. If you don’t see it immediately, click “Server” and then select “Force Showing Hidden Files.”

When you find the .htaccess file, rename it into “.htaccess.bak.” The file now exists as a backup with a .bak extension, but it won’t be taken into consideration by the server as it’s no longer a .htaccess.

Next, go to your WordPress admin panel and go to “Settings.” Select “Permalinks.” Scroll to the bottom and click “Save Changes.”

To check whether you solved the problem, try to access your website again. Now, if the 500 Internal Server Error is not there anymore, it means that the problem was caused by a bad .htaccess file. But, if you still see the 500 Internal Server Error, you will have to dig a little deeper to find the cause and solve the problem.

Plugin Deactivation

If you’re still able to access your WP admin, try solving this problem by deactivating every plugin one by one.

Again, try refreshing your website to see if the error still appears. If the error is gone, it means that it was caused by a corrupt plugin. After diagnosing what plugin caused the problem, you have two options. One, to investigate and fix the issue if you’re the plugin developer, and two, to contact the tech support team or find a replacement.

If you can’t access your WP admin, you will have to try to deactivate the plugin by accessing via the FTP client again. Open the WordPress root directory and access the wp-content folder. This folder contains all your plugins.

Rename the plugin folders to something else. This will deactivate all the plugins on your WP site. Now refresh the website to see if the internal server error is still present. If not, the problem is solved but, you still need to discover the plugin that caused the error. Start by activating plugins one by one and refreshing the website after each activation. This will help you find out which plugin is corrupt and get rid of it for good.

At the end of the process, rename your plugins folder with the original plugins name.

As you can see, this internal server error isn’t uncommon, but it does require some troubleshooting to locate it and solve it. We hope that we made the process less tiresome for you.

Exhausted Memory

Memory exhaustion is one of the most common problems that occur on websites that need a bigger PHP memory. PHP is a server-side programming language, and every WordPress website needs a WP hosting server to perform properly.

Servers operate the same as every other computer. They too need memory to effectively run multiple functions and applications on websites. That’s why server administrators portion out a certain amount of memory size for a different application that includes PHP.

In most of the cases, when your WP code needs more memory, the following message is displayed on your browser:

Fatal error: Allowed memory size of xxxxxxx bytes exhausted (tried to allocate xxxxxx bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

At first, WordPress will make an attempt to automatically grow the PHP memory limit if it’s under 64MB. But, in most cases, it’s not enough. With that, let’s have a look at how we can solve the memory limit problem.

Editing the wp-config.php File

Like in the previous solutions, you’ll have to access to your WordPress root directory with an FTP client. Or, you can access with a file manager on your hosting panel. Find the wp-config.php file and insert the following code anywhere before the line that says /* That’s all, stop editing! Happy blogging. */ at the end of the file:

define( 'WP_MEMORY_LIMIT', '256M' );

This will tell WP to raise the PHP memory limit up to 256MB. When you’re done, you need to save your changes and upload the wp-config.php file back to your server. Refresh your website to see if the error still appears.

If this solution doesn’t work, it usually means that your hosting provider does not give you permission to increase your PHP limit manually. In that case, you need to contact them and ask them to help you out.

Error Establishing a Database Connection

This is a common WordPress problem that can put you in panic mode if you don’t know how to solve it. Related to the “White screen of death”, an error in establishing a database connection means that your website can’t access the database, and consequently, crashed.

Just like any other error, this has to be fixed immediately because it can seriously damage your sales, traffic and page conversion.

Your WordPress website contains information such as posts data, page data, meta descriptions, plugin settings, login credentials, etc.

Each data resides in a MySQL database. The only type of data that is not stored in your MySQL database is your website media content (images) along with your theme central files (index.php, wp-login.php).

When a user tries to visit your website, PHP renders your website code and pulls information from the database. With that, the information on the user’s browser screen is displayed.

If this doesn’t function like it should, it will result in the following browser message:

Causes

There are few reasons that frequently cause an error in establishing database connection:

  • Wrong Database Login Credentials – Information that your WP site uses to link to your MySQL database.
  • Corrupted Database – With the ongoing adding and deleting files and plugins, corrupt databases can appear.
  • Corrupt WordPress Installation Files – Happens more often than you realize.
  • Database Server Problem – A common problem with shared hosts caused by traffic overload.

Solutions

First thing, if a problem like this appears on your WordPress website, you will have to perform a backup of your MySQL database. The next few steps will show you how to do this successfully:

Login to your cPanel account, select “Databases” and then click on “phpMyAdmin.” Select the database that you want to backup.

Click “Export.”

Choose “Quick Export.” Your database export will now be downloaded to your computer’s default download location.

The next thing you need to do is restore your MySQL database from your backup. Again, enter your cPanel account and choose the database that you want to restore.

Next, click the “Import” tab.

Click on the “Choose file” button to browse your MySQL backup file. After that, click “Go.”

Once you’ve ensured a successful backup of your MySQL database, it’s time to start solving the “Error in Establishing Database Connection” problem.

Login Credentials Checkup

The first thing when you try to solve this issue is to check your database login credentials. These details are piled in the wp-config.php file located in the WordPress root directory. This file holds important data that needs to be in a specific order to establish a database connection.

Name

// ** MySQL settings ** //
/** Name of database for WordPress */
define('DB_NAME', 'xxxxxx');

Database username

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

Hostname

/** MySQL hostname */
define('DB_HOST', 'localhost');

To access the wp-config.php file, you can either use an SFTP client like in the previous cases or, you can use the cPanel. Open your cPanel and click on “File Manager” and “Edit File.” Don’t edit anything, just ensure that the files are placed in the exact order as above.

Now, start by checking if the database name is correct. Login to your “phpMyAdmin” file under Databases.

The database names will appear on the left-hand side. Look for the dbname in your wp-congig.php file. Compare that name with your database name in the cPanel. If the names match, the problem is not located there.

Corrupt Database

Your MySQL database can become corrupt. This can happen due to countless adding and removing of plugins and tables in your WordPress website. When you log in to your WP dashboard and receive the following,

“One or more databases are unavailable”

It means that the database is corrupt. But, don’t worry! WordPress has an integrated repair mode that you can start by adding the following code to the bottom of your wp-config.php file:

define('WP_ALLOW_REPAIR', true);

After inserting the code, go to your browser and find the location of the repair mode with exampledomain.com/wp-admin/maint/repair.php. WordPress will offer you two options. One of them is to repair the database and the other one is to optimize it. When you solve a problem, quite often, the wisest choice is to repair the damage.

After you conduct the repair mode, make sure that no one else can access this by removing the code above from the wp-config.php file.

Corrupt Files

One of the reasons that can cause an error in establishing database connection is corrupt files. Corrupt files can happen due to a problem with file transfers via FTP, a hosting problem, or worse, a hacking attack. Luckily, this is also fixable. But first, you must perform a backup of your entire WordPress website.

First thing, download the latest version of WordPress. Then, unzip the WP files to your computer. Find the wp-content file and delete it. Also, look for the wp-config-sample.php file and delete that as well.

Upload the remaining files to your WordPress website with an SFTP client. With that, you will overwrite the existing files. What this does is replace every possible corrupt file and guarantees that your website now has brand new undamaged files. Cache your website and refresh it after doing this. The problem should have now disappeared from your WP website.

The 404 Not Found

WordPress is a robust CMS platform. But sometimes, a minor code error or a plugin can make your website unreachable to the users. This leads us to another common problem that developers and users face when it comes to WP – returning a 404 error.

The first thing that you need to keep in mind when you notice this type of problem is to not freak out! Your content is still on your website and the site still exists. The easiest way to fix this is by accessing to your “Permalinks” option in your WP dashboard. Enter in the dashboard, go to “Settings > Permalinks” and click the “Save Changes” button.

Normally, this will solve the 404 error. But, if the problem still appears, you can try to manually update the .htaccess file located in your WordPress root directory. For this purpose, use an FTP. Try to temporarily modify the .htaccess file by changing the permissions to 666 (don’t forget to set the permissions back to 660 when you’re done with the fix). Refresh the website to see if the problem still appears.

The 403 Forbidden

This is an error that is displayed when the server’s permission doesn’t permit access to a given page. This type of problem is usually displayed in the browser with a text like the following:

403 Forbidden – You don’t have permission to access ‘/’ on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

What Causes the 403?

The root of this problem lies in badly configured security plugins. Many of WP’s safety plugins can block an IP address if they determine that the IP address could be hostile.

Another possible reason for the 403 forbidden error is a broken .htaccess file. Let’s see how you can solve the problem if it occurs.

Deactivating Plugins

The first option that you need to try is to temporarily deactivate every plugin on your WordPress site. If this procedure solves the problem, you’ll have to figure out which plugin has caused the error and delete it from your WP site.

Start by activating all plugins, one by one, and refreshing the page. Then, when the problem occurs again, you’ll know which plugin causes the problem.

Fixing a Corrupt .htaccess File

In some cases, the 403 forbidden error happens because of a corrupt .htaccess file in your WP site. To solve this problem, you’ll need to connect to your website by using an FTP client.

Next up, you’ll need to locate the .htaccess file in the root folder of your WordPress website. Download the .htaccess file to your PC to have a backup. After downloading, delete the file from your WordPress directory.

Now, try to access your website again. If the 403 message no longer appears, it means that the .htaccess file was indeed corrupt. Now, to yield a new .htaccess file for your WordPress website you’ll need to go to your WordPress panel and open “Settings > Permalinks.”

Click on the “Save Changes” button and WordPress will generate a brand new .htaccess file for your website. Problem solved.

The Scheduled Maintenance Mode

If you use a shared hosting service for your WordPress website, it’s likely that at some point, a WordPress update process will leave your website in temporary maintenance mode. With that, your website will not be accessible to users for that period of time. This leaves them with the following message on their browser window:

Why Does It Happen?

maintenance mode page doesn’t always mean that there’s an error on your WordPress website. It can happen every time there is a WordPress update. WordPress puts your website in maintenance mode until the server updates and file extractions are done.

If everything goes well with an update, the scheduled maintenance message will not last more than few minutes. But in some cases, a slow response from a server or low memory can put your WordPress website in maintenance mode for an undetermined amount of time.

Solution

First of all, check if you’ve done your WordPress update properly. An incomplete or a blocked update process can cause problems for your website when it tries to come out of maintenance mode.

Once you’ve updated your WordPress version, you need to delete the .maintenance file from your WP root directory by using a FTP client. WordPress can hide this file from you for security purposes. If you can’t find the file, make sure that you enable the option to display hidden files in FileZilla by clicking on “Server > Force showing hidden files.”

Initially, WordPress creates the .maintenance file when the updating process occurs. If you don’t remove this file from your WordPress root directory, your website can stay in maintenance mode forever.

What Can You Do to Prevent WordPress Errors

The problems above may appear, but luckily can be solved like every other WordPress problem. Although, prevention is always better than having to deal with problems when they occur. So, what can you do to protect your WordPress website from these unwanted situations?

  • Regular Updates – An out of date WordPress version or an old WP theme can cause a serious mess to your online presence. Files will not be synchronized and some of the page’s functions will stop working altogether because they depend on programs and plugins that need an update.
  • Plugin Checkup – WordPress is an open source CMS platform. This means that every developer can attach his work and contribute. But, the quality of plugins in WP often differs because of this and can lead to some of the problems above. That’s why you need to check, re-check, and deletion of every plugin that causes problems with your site.
  • Theme Checkup – Themes can get corrupted and infected just like plugins do. This can block your website functions. Before you buy a theme for your WordPress website, make sure that the theme is tested, and that you’ll have an ongoing support from the theme authors.
  • Inspect .htaccess file – As you learned from this article, the .htaccess file controls a lot of security aspects of your WordPress website. This includes permalinks and redirects. There are safety plugins that modify this file to prevent access from suspicious IP addresses. Follow the steps above to ensure a healthy .htaccess file that doesn’t cause problems with your site.

Wrapping up

There you have it, the most common errors that WordPress developers encounter finally revealed to you. We hope that this article can help you navigate these common problems. Problems that can, unfortunately, disable your WordPress website.

Even if they look simple, WordPress websites and platforms work like Swiss clocks- dependable and functional but full of complex mechanisms (code and plugins) that keep things running smoothly. And because of this, sometimes, the solutions for WordPress problems are not always easy.

When you’re not sure if you can solve those problems/errors, it’s always a wise choice to approach professionals for safer WP updates and continuous monitoring. At the end of the day, problem-solving is a serious process and key to a successful business and better sales. Don’t miss out on potential customers because of a dysfunctional online presence.

Leave a Reply

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