How to Fix “Warning Cannot Modify Header Information” in WordPress

Want to remove the “warning cannot modify header information” error from your WordPress website?

This is a common WordPress error, and it’s one of the few WordPress errors that offer details that can be used to remove it from your site.

In this article, we will show you how to read the error to learn what caused it and then the steps you need to take to remove it from your WordPress website.

Let’s dive into the tutorial. 🤿

What causes the “warning cannot modify header information – headers already sent by” error

the Warning Cannot Modify Header Information error

The error is caused due to faulty code in your page header. It is triggered because of reasons like:

  • Including white spaces before or after the “<?PHP” and “?> PHP” tags in one of your site’s PHP files
  • Having a print / echo statement or an HTML block that’s added before the PHP header function
  • Small issues such as typos, incorrect software configuration, header misplacement, among other things

You are likely to encounter it when while installing or updating some software on your WordPress website.

In the next section, you will 👨‍🎓 learn how to remove the error from your site.

How to fix the “warning Cannot modify header information” error in WordPress

To fix the “warning cannot modify header information” error, you need to first locate the exact cause of the error and then proceed to fix the corrupted file.

👉 We will show you the exact steps you need to take. Let’s get started.

Step 1: Locating the cause of the error

You can discover the exact cause of the error by reading the text of the error message. For instance, we encountered the following error on our demo site:

Warning: Cannot modify header information – headers already sent by (output started at /public_html/wp-content/plugins/redirection/redirection-settings.php:3/) in /public_html/wp-includes/pluggable.php on line 33

💡 IMPORTANT: Before we proceed, please know that the error will look very different on your website. On our demo site, the error was caused by a plugin called Redirection, but on your website, the error could be caused by a different plugin. Or it could be caused by a theme or one of the WordPress core files. Please know that, despite the differences in its source, the structure of the error remains the same.

So in the following paragraph, we are going to break down the structure of the error and show you how to read it.

How to read the error 📚

We are going to divide the error into three parts:

  • Part 1: Warning: Cannot modify header information – headers already sent by
  • Part 2: (output started at /public_html/wp-content/plugins/redirection/redirection-settings.php:3/)
  • Part 3: in /public_html/wp-includes/pluggable.php on line 33

Part 1 is the name of the error. Part 2 offers details of the file that’s causing the error and needs fixing. And Part 3 indicates a file that is unable to work properly because of the broken file in Part 2.

Our focus should be on Part 2, as it is the source of the error. Let’s break it down to further our understanding of it:

  • public_html/wp-content/plugins – These are folders of your website. You will need to access them in the next section to fix the error.
  • redirection – This is a plugin because it is located in the “plugins” folder
  • redirection-settings.php – This is a file located inside the “redirection” plugin and a piece of code or too many white spaces inside this file is causing the error
  • 3 – This indicates which line inside the “redirection-settings.php” file is causing the error
reading the Warning Cannot Modify Header Information error

Do you see how the error is showing you the real cause for its appearance? Next, you will learn how to fix the error.

Step 2: Fixing the error

There are two ways to fix the “warning cannot modify header information” error on your WordPress website. Let’s take a look at each solution.

Before you proceed any further, please take a backup of your entire website. In the following tutorial, you will be asked to replace and edit your WordPress files. And these activities are known to break websites. A backup will be your safety net for when things go wrong. So make sure you have a backup before proceeding.

1. Uninstall or replace software (recommended)

In Step 1 we showed you how to locate the cause of the error. So by now, you must know which software is causing the error on your website.

We recommend uninstalling the software and reinstalling it again.

If the error persists, then download a new copy of the software and install it on your website. The previous copy will be automatically replaced with the new one. Just make sure you are installing the same software version.

If you can’t access your WordPress admin, then you need to go to the backend of your website to replace the software.

The backend of your site can be accessed by your hosting account cPanel or an FTP client like Filezilla. We will show you how to use the cPanel. If you prefer using an FTP client, we have a separate FTP guide on that.

Uninstall or replace software using cPanel

To access the cPanel open your hosting account and select cPanel. The location of the cPanel will differ from hosting to hosting. Check the help docs of your hosting to locate the cPanel.

locating cpanel in hosting account

In the cPanel, select File Manager located in the Files section.

locating file manager in cpanel

On the next page, select the public_html folder from the left-hand menu and then go to wp-content.

Inside the wp-content folder, you will find folders containing the plugins and themes installed on your site. Open the plugins or themes folder, depending on which software you are planning to replace.

locating themes and plugins folders

Now you will need to download a fresh copy of the plugin or theme to your local computer. Premium plugins and themes are bought from a marketplace or the official website of the software. Free plugins can be found here, and free themes can be found here.

After downloading a fresh copy of the software, be sure to unzip or extract it.

extracting zipped folder

Then go to the plugins or themes folder on the File Manager and upload the software into the folder.

uploading folder in file manager - warning cannot modify header information

At this point, your hosting provider will warn you because you are trying to upload a file that already exists. Bypass the warning by selecting the Okay or Replace button.

To replace the WordPress core, you will need to take a separate set of steps, and reinstall WordPress manually.

Once done, go to your website and check if the “warning cannot modify the header information” error is gone.

💡 IMPORTANT: Still seeing the error? Sometimes, errors appear on the site even after they are gone due to caching. Before you try the next solution, be sure to clear your cache and check again.

2. Edit the corrupted file

Back in Step 1, we showed you how to identify the file causing the error. You can use that information to edit the file and fix it.

For instance, on our demo site, we know that the problem stems from a file called “redirection-settings.php” located in the Redirection plugin folder. We even know that line no 3 in that file is causing the error.

Likewise, pinpoint the file causing the error on your website and then open the file via the File Manager or an FTP client.

We used File Manager to open the culprit file on our demo site. All we had to do is right-click on the file and select the Edit button.

editing a wordpress file - warning cannot modify header information

One has to be technically savvy to spot an error on a WordPress file. So it’s perfectly fine if you can’t spot the problem in your culprit file.

Take a screenshot of the file and the error, reach out to the plugin or theme developers, and seek help. If an error is caused by a WordPress core file, then leave a comment at the WordPress support forum. Make sure you are not revealing your site’s name or URL to prevent security risks.

Conclusion 🏁

The “warning cannot modify header information” is a common WordPress error, and unlike other WordPress errors, it tells us what caused the error to appear on the site.

The solution involves either replacing the culprit software with a fresh copy or going to the backend of the site to edit the culprit file. Needless to say, editing a WordPress file is risky, and a backup should be taken before proceeding with such steps.

For some other tips on solving WordPress errors, you can also check out our general guide to 👉 WordPress troubleshooting.

If you still have any questions about the “warning cannot modify header information” error, let us know in the comments below.

Free guide

5 Essential Tips to Speed Up
Your WordPress Site

Reduce your loading time by even 50-80%
just by following simple tips.

Leave a Reply