“Cannot modify header information - headers already sent”
Fix the PHP headers already sent warning: stray whitespace, byte order marks and output before redirects or cookies.
On this page
Does this match what you’re seeing?
- Warning: Cannot modify header information - headers already sent by (output started at ...)
- Redirects or logins stop working
- The problem appeared after editing a PHP file
Warning: Cannot modify header information - headers already sent by (output started at /home/user/domains/yourdomain.co.uk/public_html/wp-config.php:1)Headers — redirects, cookies, content type — must be sent before any page content. Something output content first, so the later header couldn’t be sent.
The message tells you where
”output started at ... wp-config.php:1” is the file and line that produced the early output. Go there, not to the file named at the start of the warning.
The usual causes
- Whitespace before
<?php— a blank line or space at the very start of the file. - Whitespace after a closing
?>at the end of a file. The fix is to delete the closing?>entirely; it’s optional at the end of PHP files. - A byte order mark (BOM) — an invisible character some editors add to UTF-8 files. Re-save as “UTF-8 without BOM”.
echo,printor HTML before aheader()orsetcookie()call.
Fixing it
- Open the file named after “output started at” in a code editor (the File Manager editor works).
- Remove anything before
<?phpon line 1. - Remove a closing
?>and anything after it at the end of the file. - Save as UTF-8 without BOM.
Editing tip
Word processors and some basic editors add hidden characters. Use a code editor.
Choosing a host for a PHP project? Every Traxio account runs PHP 7.4 to 8.4 with a MySQL database: see PHP and MySQL hosting, £0.99 a month.
If it doesn’t work
These guides cover the most common problems, starting with what you can see. Or browse every fix for a common problem.
- 500 Internal Server Error: how to fix itFind the real cause of a 500 error: read the error log, then check .htaccess, PHP errors, permissions and PHP version in order.
- Understanding PHP error messagesHow to read a PHP error: fatal errors, parse errors, warnings, notices and deprecations, what each means for your site, and where to look next.
- Blank white page: how to find the hidden errorA completely blank page usually means a PHP error that isn’t displayed. How to reveal it with logs and fix the cause.
Common questions
What does “headers already sent” mean?
Your script tried to send a header — a redirect, a cookie — after output had already started. The usual culprit is a blank line or a stray space before the opening <?php tag in an included file. The error message names the file and line that produced the output.
Spotted something out of date or unclear? Tell us and we’ll fix it.