5 Common WordPress Errors and their Simple Solutions

Internal Server Error 500

Right now, someone somewhere is in the exact same boat as you – what with the weird WordPress error you are confronting. So relax, pal. You’re not alone. And that “fatal” error isn’t as apocalyptic as you think.

wodpress error

Therefore, before you are officially allowed to even think about freaking out, look carefully at the error message. It’s your website trying to tell you what’s wrong. Now scroll down and see if your particular WordPress error is somewhere on the list.

1. Cannot modify header information – headers already sent

What:

You receive a warning as you try to access your website in the browser which starts like this,

Cannot modify header information – headers already sent by …”.

Why:

The error occurs when there are characters/spaces/new code snippets before and/or after the closing and opening tags in wp-config.php or some other file.

How to resolve the issue:

  • First, understand where the problem is. The error message will tell you. Check out this example:

Warning: Cannot modify header information – headers already sent by (output started at /path/blog/wp-config.php:44) in /path/blog/wp-login.php on line 32

See that message within the brackets? THAT’S your error origin. In this case, line #44 of wp-config.php

  • Next, find the file where this error originated in your WordPress installation directory. Open it in Notepad or another plain text editor.
  • Make sure that there are no characters/spaces/lines before <?php
  • Make sure that there are no characters/spaces/lines after  ?>
  • Save the file with UTF-8 encoding via ‘Save as’ Screen:

errors

  • Upload it to the WordPress installation directory using FTP

Tip: Using wp_redirect() after header (or any other content) has been sent can also cause this error. (Ask your friendly neighborhood developer to) Use JavaScript redirection instead.

2. Allowed memory size exhausted

What:

You receive a warning as which says,

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 131072 bytes) in /home/yourwebsite/public_html/wp-admin/includes/template.php”.

Why:

This error occurs when your website is running on low on memory allocated to PHP. Usually, the WordPress default is 32 MB, but if your website is loaded with plugins and/or receives moderate to high amount of traffic, you’ll need to increase the allocated memory.

How to resolve the issue:

  • First, check with your hosting provider that you’re allowed to increase the memory allocated to PHP. If not, inform them of the issue and ask for increased PHP memory limit.
  • Next, open wp-config.php file and add this code to increase PHP memory to 256 MB :
    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

Note: WordPress cannot extend the memory limit beyond 256 MB with this method. But it is possible through some tampering with the core files, which you should not carry out on your own. Contact your hosting provider or WordPress developer to extend it further than max limit.

3. Cannot Create/Write to File (Error code: 13)

What:

You receive a warning as you try to access your website in the browser which starts like this,

WordPress database error: [Can’t create/write to file ‘/filename’ ‘ (Errcode: 13)]

Why:

This error occurs when MySQL is unable to create a temporary file (in tmpdir aka temporary directory).

How to resolve the issue:

This is a slightly tricky operation, and you might want to hand it off to your friendly neighborhood developer. But if you’re feeling up to it, here’s how you can alter the tmpdir variable to a writable directory.

4. Error 145

What:

You receive the following warning about your database that says,

MySQL error code 145 = Table was marked as crashed and should be repaired.”

Why:

This can happen due to poor server configuration or an unexpected slip during database optimization. Basically, it’s exactly what it says on the tin: your database has been damaged/ corrupted and needs to be repaired.

How to resolve the issue:

To fix this, you’ll need to gain access to phpMyAdmin. Once you have that (contact your hosting provider for info), proceed as follows:

  • Backup your database or make sure you have one.
  • Login to cPanel, go to phpMyAdmin and select the database of error origin (named in the error message itself).
  • Check any other tables mentioned in the error and select ‘Repair Table’ from the drop down menu at the bottom.
  • If the error persists, reinstall the database(s) manually.

Note: If you’re apprehensive about messing with the database tables, you can ask your hosting provider to run check/repair too.

5. Maximum Execution Time Exceeded

What:

An error message on your website says,

Fatal Error: Maximum execution time of 30 seconds exceeded in /file-path.php on line 538.

Why:

This happens when a PHP script is taking too long to process. Usually, hosting providers use set_time_limit() PHP function to prevent server abuse.

How to resolve the issue:

Before we progress further, make sure you have a complete backup of your website and database.

Now, you can fix this by editing .htaccess or php.ini. If you’re hosted on a shared server, you may need to contact your hosting provider to gain access to these files (if you don’t have it already).

  • Method 1: .htaccess

Add the following code to .htaccess file to stretch execution time from default 30 seconds to 60 seconds.

php_value max_execution_time 60

  • Method 2: php.ini

Add the following code to php.ini to set execution time to 60 seconds:

max_execution_time = 60

Note: You can also use the WP Maximum Execution Time Exceeded plugin for the same effect (sets time to 60 seconds only).

Endnote

As long as you keep your wits about you, the errors (even the ones that say ‘Fatal’) can be resolved with minimum damage. And if you can’t or simply prefer not to dabble in code, find yourself a WordPress development company to run maintenance and upkeep for you.

email