Skip to content
WordPress3 min read

Cannot modify header information - headers already sent: how to fix it

Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/wp-config.php:1)

Short answer

This warning means a PHP file printed output, even a single space, before WordPress sent HTTP headers such as a redirect or a cookie. The guilty file is the one after "output started at" in the message; the fix is usually removing whitespace before <?php or after ?>, or saving the file without a BOM.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What the error means
  2. Common causes
  3. How to fix it
  4. Prevention
  5. On ArabyHost

This warning comes from PHP, not from WordPress itself. In practice it shows up as a blank page after logging in, a login loop that never ends, warning text at the top of the page, or a full white screen.

What the error means

HTTP headers must be sent before any content. As soon as PHP outputs a single character, even a space or an empty line, the headers count as sent, and any later call to header(), setcookie() or wp_redirect() fails.

The message names two locations, and the first one is what matters:

Warning: Cannot modify header information - headers already sent by
(output started at /home/user/public_html/wp-config.php:1)
in /home/user/public_html/wp-includes/pluggable.php on line 1450
  • output started at .../wp-config.php:1 is the file and line that caused it.
  • pluggable.php is where PHP noticed the problem. Don’t edit it.

Common causes

  • A space or empty line before <?php at the top of a file.
  • A space or line after the closing ?> at the end of a file, especially wp-config.php or functions.php.
  • The file was saved as UTF-8 with BOM: three invisible bytes some editors put at the start of a file.
  • A plugin or theme that echoes text before headers are sent.
  • PHP warnings shown on screen: a Deprecated or Notice message printed at the top becomes the first output.

How to fix it

  1. Find the file from the message: copy the path after output started at and the line number. If the warning isn’t visible on the page, look in cPanel under Metrics › Errors, or in the error_log file in the site’s folder.
  2. Open the file in Files › File Manager and click Edit.
  3. Delete anything before <?php: it must be the very first thing in the file, on line 1, with nothing before it.
  4. Remove the closing ?> from files that contain only PHP. WordPress coding standards recommend this, and it prevents the problem entirely:
<?php
define( 'DB_NAME', 'example_db' );
// ... other settings
require_once ABSPATH . 'wp-settings.php';
// end of file: no closing tag and no blank lines after it
  1. Remove the BOM: if the line is 1 and you see no space, a BOM is the likely cause. Open the file in an editor such as VS Code or Notepad++, save it as plain UTF-8 instead of “UTF-8 with BOM”, and upload it over the old one. With SSH you can find affected files with:
grep -rl $'\xEF\xBB\xBF' ~/public_html --include=*.php
  1. If the file belongs to a plugin or theme, disable it by renaming its folder, for example wp-content/plugins/my-plugin to my-plugin-off, then update it or report it to the developer.
  2. Stop showing warnings to visitors while still logging them, by adding this to wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Errors then go to wp-content/debug.log. Set WP_DEBUG back to false when you’re done.

Prevention

  • Use an editor that saves UTF-8 without BOM, and avoid editing PHP files in old Windows Notepad.
  • Don’t end PHP files with ?>.
  • When pasting snippets into functions.php, don’t add a second <?php tag or blank lines outside the code. A child theme or a code-snippets plugin is safer.
  • Keep display_errors off on the live site.
  • If an edit broke the whole site instead, see PHP Parse error.

On ArabyHost

You don’t need SSH for this fix: the File Manager editor in cPanel, one click away from the Araby Panel, is enough to edit wp-config.php or functions.php. The Araby AI assistant reads the error log and points you to the exact file and line. JetBackup keeps a daily copy of your files, so if an edit breaks the site you can restore the file as it was. See our WordPress hosting.

FAQ

Which file do I edit, the first or the second one in the message?

Edit the file after "output started at": that's the one that sent output too early. The second file, usually pluggable.php, is only where PHP noticed the problem, so leave it alone.

Does hiding warnings fix it?

Only when the early output is itself a warning, such as a Deprecated notice. Stray spaces and a BOM are sent to the browser even with warnings hidden, so they must be removed from the file.

Why did this start after I edited functions.php?

The pasted code most likely added a blank line, a second <?php tag or a space after ?> at the end of the file. Open the file in File Manager and remove or correct what you added.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.