{"id":5074,"date":"2026-06-25T14:28:39","date_gmt":"2026-06-25T14:28:39","guid":{"rendered":"https:\/\/www.copahost.com\/blog\/?p=5074"},"modified":"2026-06-25T14:33:13","modified_gmt":"2026-06-25T14:33:13","slug":"cannot-modify-header-information-headers-already-sent-by-how-to-fix-it","status":"publish","type":"post","link":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/","title":{"rendered":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>The error &#8220;Warning: Cannot modify header information &#8211; headers already sent by&#8221; means a PHP script tried to send HTTP headers (for a redirect, cookie, or page setting) after content had already been sent to the browser. The usual cause is stray output \u2014 a blank space, line break, or text \u2014 before the headers, most often whitespace before <code>&lt;?php<\/code> or after <code>?><\/code> in a file. The good news: the error message tells you exactly which file and line to fix.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover-1024x576.png\" alt=\"WordPress cannot modify header information headers already sent error\" class=\"wp-image-5075\" srcset=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover-1024x576.png 1024w, https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover-300x169.png 300w, https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover-768x432.png 768w, https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover-1536x864.png 1536w, https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png 1672w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re seeing this warning across the top of your site \u2014 often after installing a plugin, editing your theme, or adding a redirect \u2014 don&#8217;t panic. It looks cryptic, but it&#8217;s one of the more logical WordPress errors to fix, because the message itself points you to the culprit. The trick is knowing how to read it, which is exactly what this guide will show you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What &#8220;headers already sent&#8221; means<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When a browser requests a page, the server must send <strong>HTTP headers first<\/strong> (invisible instructions like content type, cookies, and redirects), and only then the <strong>content<\/strong> (the HTML you see). That order is fixed by the HTTP protocol.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;headers already sent&#8221; error happens when a PHP script tries to send a header \u2014 through a function like <code>header()<\/code>, <code>wp_redirect()<\/code>, <code>setcookie()<\/code>, or <code>session_start()<\/code> \u2014 <strong>after<\/strong> some content has already gone to the browser. Once output has started, it&#8217;s too late to send headers, so PHP throws the warning. You may also see it phrased simply as <strong>&#8220;headers already sent&#8221;<\/strong> or <strong>&#8220;cannot modify header information&#8221;<\/strong> \u2014 it&#8217;s the same error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This matters beyond the warning text itself: because the failed header is often a redirect, a cookie, or a login action, those features can silently stop working \u2014 broken redirects, users unable to log in, or sessions that won&#8217;t start \u2014 until the underlying output is removed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;content&#8221; that slips out early is usually invisible: a stray space or blank line, a forgotten <code>echo<\/code>, or hidden characters in a file. That&#8217;s why this error feels mysterious until you know where to look.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The key skill: how to read the error message<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is what most people get wrong \u2014 and it&#8217;s the fastest way to fix the error. The message has <strong>three parts<\/strong>, and they don&#8217;t all mean the same thing:<\/p>\n\n\n\n<div style=\"margin:24px 0; font-family:inherit;\">\n  <div style=\"background:#1A2238; border-radius:10px; padding:18px 20px; overflow-x:auto; margin-bottom:14px;\">\n    <code style=\"display:block; color:#FFD9C2; font-family:'Courier New',monospace; font-size:13px; line-height:1.7; white-space:pre;\">Warning: Cannot modify header information - headers already sent by\n(output started at \/public_html\/wp-content\/themes\/mytheme\/functions.php:42)\nin \/public_html\/wp-includes\/pluggable.php on line 1450<\/code>\n  <\/div>\n\n  <div style=\"display:flex; flex-direction:column; gap:10px;\">\n    <div style=\"display:flex; align-items:flex-start; gap:12px; background:#FFF4ED; border:1px solid #FBD9C0; border-radius:8px; padding:12px 14px;\">\n      <div style=\"flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#1A2238; color:#fff; font-weight:700;\">1<\/div>\n      <div style=\"color:#334155; line-height:1.6;\"><strong style=\"color:#1A2238;\">The error name.<\/strong> &#8220;Cannot modify header information \u2013 headers already sent by.&#8221; Tells you what kind of problem it is.<\/div>\n    <\/div>\n    <div style=\"display:flex; align-items:flex-start; gap:12px; background:#FFF4ED; border:1px solid #FBD9C0; border-left:4px solid #F26C21; border-radius:8px; padding:12px 14px;\">\n      <div style=\"flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#F26C21; color:#fff; font-weight:700;\">2<\/div>\n      <div style=\"color:#334155; line-height:1.6;\"><strong style=\"color:#B45309;\">&#8220;output started at \u2026 :42&#8221; \u2014 THIS is the file to fix.<\/strong> The file and line where the stray output began. This is your culprit. Go here.<\/div>\n    <\/div>\n    <div style=\"display:flex; align-items:flex-start; gap:12px; background:#FFF4ED; border:1px solid #FBD9C0; border-radius:8px; padding:12px 14px;\">\n      <div style=\"flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#1A2238; color:#fff; font-weight:700;\">3<\/div>\n      <div style=\"color:#334155; line-height:1.6;\"><strong style=\"color:#1A2238;\">&#8220;in \u2026 pluggable.php on line 1450&#8221; \u2014 do NOT edit this.<\/strong> Usually a WordPress core file that simply failed because of part 2. It&#8217;s the victim, not the cause.<\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The crucial insight: <strong>the file in &#8220;output started at&#8221; is the one you fix<\/strong> \u2014 that&#8217;s where the stray output began. The file at the end (&#8220;in \u2026 on line \u2026&#8221;) is usually a WordPress core file like <code>pluggable.php<\/code> that simply <em>failed<\/em> because of the first file. <strong>Don&#8217;t edit that core file<\/strong> \u2014 it&#8217;s the victim, not the cause. Beginners often waste time editing the wrong file; reading the message correctly avoids that entirely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So your first step is always: read the message, note the file and line in the <strong>&#8220;output started at&#8221;<\/strong> part, and go there.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common causes<\/h2>\n\n\n\n<div style=\"margin:24px 0; overflow-x:auto; font-family:inherit; color:#1A2238;\">\n  <table style=\"width:100%; border-collapse:separate; border-spacing:0; border:1px solid #FBD9C0; border-radius:12px; overflow:hidden; min-width:520px;\">\n    <thead>\n      <tr style=\"background:#1A2238; color:#fff; text-align:left;\">\n        <th style=\"padding:12px 14px;\">Cause<\/th>\n        <th style=\"padding:12px 14px;\">What it looks like<\/th>\n      <\/tr>\n    <\/thead>\n    <tbody>\n      <tr style=\"background:#FFF4ED;\"><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; font-weight:700; color:#1A2238;\">Whitespace (most common)<\/td><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; color:#334155;\">A space or blank line before <code style=\"font-family:'Courier New',monospace; color:#B45309;\">&lt;?php<\/code> or after <code style=\"font-family:'Courier New',monospace; color:#B45309;\">?&gt;<\/code>. Invisible, but counts as output.<\/td><\/tr>\n      <tr><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; font-weight:700; color:#1A2238;\">Premature output<\/td><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; color:#334155;\">A stray <code style=\"font-family:'Courier New',monospace; color:#B45309;\">echo<\/code>, <code style=\"font-family:'Courier New',monospace; color:#B45309;\">print<\/code>, HTML, or leftover debug code before a header call.<\/td><\/tr>\n      <tr style=\"background:#FFF4ED;\"><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; font-weight:700; color:#1A2238;\">Plugin or theme<\/td><td style=\"padding:11px 14px; border-bottom:1px solid #FBE4D5; color:#334155;\">Badly coded extension outputting early \u2014 often right after an update.<\/td><\/tr>\n      <tr><td style=\"padding:11px 14px; font-weight:700; color:#1A2238;\">BOM (hidden bytes)<\/td><td style=\"padding:11px 14px; color:#334155;\">File saved as &#8220;UTF-8 with BOM&#8221; adds invisible characters before your code.<\/td><\/tr>\n    <\/tbody>\n  <\/table>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">By far the most common is <strong>whitespace<\/strong> \u2014 a space or blank line before the opening <code>&lt;?php<\/code> or after the closing <code>?&gt;<\/code> tag. It&#8217;s invisible in most editors but counts as output, so the headers fail. The second most common is a <strong>plugin or theme<\/strong> introducing premature output, especially right after an update.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to fix it<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1 \u2014 Open the file the message points to<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using your hosting <strong>File Manager<\/strong> or an <a href=\"https:\/\/www.copahost.com\/blog\/ftp-meaning\/\">FTP client<\/a>, open the file named in the <strong>&#8220;output started at&#8221;<\/strong> part of the message, and go to the line number it gives. (If your dashboard still works and the file is a theme or plugin file, you can sometimes use the built-in editor \u2014 but FTP is safer.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Always back up the file before editing it.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2 \u2014 Remove the stray output<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Look at the indicated line and the lines just before it. You&#8217;re hunting for output that shouldn&#8217;t be there:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Whitespace before <code>&lt;?php<\/code><\/strong> \u2014 delete any spaces or blank lines at the very top of the file, so <code>&lt;?php<\/code> is the very first thing.<\/li>\n\n\n\n<li><strong>Whitespace or blank lines after <code>?><\/code><\/strong> \u2014 better yet, in files that are pure PHP (like <code>wp-config.php<\/code> and <code>functions.php<\/code>), <strong>remove the closing <code>?><\/code> entirely<\/strong>. PHP doesn&#8217;t require it, and removing it eliminates this whole class of error.<\/li>\n\n\n\n<li><strong>Stray <code>echo<\/code>, <code>print<\/code>, <code>var_dump<\/code>, or HTML<\/strong> before a header call \u2014 remove leftover debug code or markup that runs before headers are sent.<\/li>\n<\/ul>\n\n\n\n<div style=\"display:flex; align-items:flex-start; gap:12px; background:#F0FDF4; border:1px solid #BBF7D0; border-left:4px solid #16A34A; border-radius:8px; padding:14px 16px; margin:18px 0; font-family:inherit;\">\n  <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#16A34A\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"flex:0 0 auto; margin-top:2px;\"><path d=\"M22 11.08V12a10 10 0 1 1-5.93-9.14\"><\/path><polyline points=\"22 4 12 14.01 9 11.01\"><\/polyline><\/svg>\n  <div style=\"color:#14532D; line-height:1.6;\"><strong style=\"color:#15803D;\">Best practice:<\/strong> in files that are pure PHP \u2014 like <code style=\"background:#fff;padding:1px 5px;border-radius:4px;color:#B45309;font-family:'Courier New',monospace;\">wp-config.php<\/code> and <code style=\"background:#fff;padding:1px 5px;border-radius:4px;color:#B45309;font-family:'Courier New',monospace;\">functions.php<\/code> \u2014 simply delete the closing <code style=\"background:#fff;padding:1px 5px;border-radius:4px;color:#B45309;font-family:'Courier New',monospace;\">?&gt;<\/code> tag at the end. PHP doesn&#8217;t need it, and removing it means stray whitespace after it can never cause this error again.<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3 \u2014 If it&#8217;s a plugin or theme<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the &#8220;output started at&#8221; file lives in <code>\/wp-content\/plugins\/<\/code> or <code>\/wp-content\/themes\/<\/code>, the culprit is that extension:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Update it<\/strong> \u2014 if the plugin&#8217;s code caused it, the developer may have already released a fix.<\/li>\n\n\n\n<li><strong>Deactivate it<\/strong> to confirm. If you can&#8217;t reach the dashboard, rename the plugin&#8217;s folder (or the whole <code>\/wp-content\/plugins\/<\/code> folder) via FTP to force-deactivate, then rename it back once fixed.<\/li>\n\n\n\n<li><strong>Reinstall<\/strong> a fresh copy if the file is simply corrupted.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4 \u2014 Check for a BOM (hidden characters)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;ve checked for whitespace and found nothing, the file may have been saved with a <strong>BOM (Byte Order Mark)<\/strong> \u2014 invisible bytes that some editors add when saving as &#8220;UTF-8 with BOM.&#8221; Re-save the file as <strong>UTF-8 without BOM<\/strong> in a proper code editor. This sends output before your code even runs, and is a sneaky cause when everything <em>looks<\/em> clean.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For developers: output buffering and hooks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re writing the code yourself, two proper fixes: wrap early output with <strong><code>ob_start()<\/code><\/strong> (output buffering) so headers can still be sent, or \u2014 better \u2014 make sure redirects and header calls run <strong>before<\/strong> any output, by hooking into an early action like <code>template_redirect<\/code> rather than inside a template. This addresses the cause rather than masking it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where this connects<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is a PHP <strong>output<\/strong> error, not a resource limit \u2014 but it&#8217;s still a PHP error you&#8217;ll find in your <a href=\"https:\/\/www.copahost.com\/blog\/wordpress-error-logs\/\">error log<\/a>, and it&#8217;s one of the <a href=\"https:\/\/www.copahost.com\/blog\/common-wordpress-errors\/\">common WordPress errors<\/a>. If the stray output is severe enough that the page renders completely blank instead of showing the warning, see our guide on the <a href=\"https:\/\/www.copahost.com\/blog\/wordpress-white-screen-of-death\/\">white screen of death<\/a> \u2014 the whitespace-after-<code>?&gt;<\/code> cause is the same family of problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A related point: this warning only shows on screen when <code>display_errors<\/code> (or <code>WP_DEBUG<\/code>) is enabled \u2014 on a production site it often goes to the error log instead. Be wary of &#8220;fixes&#8221; that simply turn <code>display_errors<\/code> off: that only hides the message, leaving the broken headers (and whatever redirect or cookie they affect) still failing underneath. Always fix the stray output itself, not the visibility of the warning.<\/p>\n\n\n\n<div style=\"display:flex; align-items:flex-start; gap:12px; background:#EFF6FF; border:1px solid #BFDBFE; border-left:4px solid #2563EB; border-radius:8px; padding:14px 16px; margin:18px 0; font-family:inherit;\">\n  <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#2563EB\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"flex:0 0 auto; margin-top:2px;\"><circle cx=\"12\" cy=\"12\" r=\"10\"><\/circle><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"><\/line><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"><\/line><\/svg>\n  <div style=\"color:#1E3A5F; line-height:1.6;\"><strong style=\"color:#1E40AF;\">Caching tip:<\/strong> after you fix the file, a cached version of the page may still show the warning. Clear your site and server cache (and your browser cache) before deciding the fix didn&#8217;t work.<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<div style=\"margin:20px 0; font-family:inherit;\">\n\n  <div style=\"border:1px solid #FBD9C0; border-radius:10px; padding:16px 18px; margin-bottom:12px; background:#fff;\">\n    <div style=\"font-weight:700; color:#1A2238; margin-bottom:6px;\">What does &#8220;cannot modify header information &#8211; headers already sent by&#8221; mean?<\/div>\n    <div style=\"color:#334155; line-height:1.6;\">It means a PHP script tried to send HTTP headers (like a redirect or cookie) after content had already been sent to the browser. Since HTTP requires headers before content, PHP refuses and shows the warning. The &#8220;content&#8221; is usually stray whitespace or output before the headers.<\/div>\n  <\/div>\n\n  <div style=\"border:1px solid #FBD9C0; border-radius:10px; padding:16px 18px; margin-bottom:12px; background:#fff;\">\n    <div style=\"font-weight:700; color:#1A2238; margin-bottom:6px;\">Which file do I actually need to fix?<\/div>\n    <div style=\"color:#334155; line-height:1.6;\">The one named in the &#8220;output started at&#8221; part of the message \u2014 that&#8217;s where the stray output began. The file at the end (&#8220;in \u2026 on line \u2026&#8221;) is usually a WordPress core file like pluggable.php that just failed as a result; don&#8217;t edit it. Always fix the &#8220;output started at&#8221; file.<\/div>\n  <\/div>\n\n  <div style=\"border:1px solid #FBD9C0; border-radius:10px; padding:16px 18px; margin-bottom:12px; background:#fff;\">\n    <div style=\"font-weight:700; color:#1A2238; margin-bottom:6px;\">What&#8217;s the most common cause?<\/div>\n    <div style=\"color:#334155; line-height:1.6;\">Whitespace \u2014 a space or blank line before the opening &lt;?php tag or after the closing ?&gt; tag. It&#8217;s invisible in most editors but counts as output. Removing it (or removing the closing ?&gt; from pure-PHP files entirely) usually fixes the error.<\/div>\n  <\/div>\n\n  <div style=\"border:1px solid #FBD9C0; border-radius:10px; padding:16px 18px; margin-bottom:12px; background:#fff;\">\n    <div style=\"font-weight:700; color:#1A2238; margin-bottom:6px;\">The error points to a plugin file \u2014 what do I do?<\/div>\n    <div style=\"color:#334155; line-height:1.6;\">Update the plugin first (the developer may have fixed it), then deactivate it to confirm it&#8217;s the cause. If you can&#8217;t reach your dashboard, rename the plugin&#8217;s folder via FTP to force-deactivate it, then rename it back after fixing or replacing it.<\/div>\n  <\/div>\n\n  <div style=\"border:1px solid #FBD9C0; border-radius:10px; padding:16px 18px; background:#fff;\">\n    <div style=\"font-weight:700; color:#1A2238; margin-bottom:6px;\">I fixed the file but still see the error \u2014 why?<\/div>\n    <div style=\"color:#334155; line-height:1.6;\">Usually caching. A cached copy of the page can still show the warning after you&#8217;ve fixed it. Clear your site cache, server cache, and browser cache, then reload. If it persists, check for a BOM (save the file as UTF-8 without BOM) or another file with stray output.<\/div>\n  <\/div>\n\n<\/div>\n\n\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\"@type\":\"Question\",\"name\":\"What does \\\"cannot modify header information - headers already sent by\\\" mean?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It means a PHP script tried to send HTTP headers (like a redirect or cookie) after content had already been sent to the browser. Since HTTP requires headers before content, PHP refuses and shows the warning. The content is usually stray whitespace or output before the headers.\"}},\n    {\"@type\":\"Question\",\"name\":\"Which file do I actually need to fix?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"The one named in the output started at part of the message \u2014 that's where the stray output began. The file at the end (in \u2026 on line \u2026) is usually a WordPress core file like pluggable.php that just failed as a result; don't edit it. Always fix the output started at file.\"}},\n    {\"@type\":\"Question\",\"name\":\"What's the most common cause?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Whitespace \u2014 a space or blank line before the opening PHP tag or after the closing PHP tag. It's invisible in most editors but counts as output. Removing it (or removing the closing tag from pure-PHP files entirely) usually fixes the error.\"}},\n    {\"@type\":\"Question\",\"name\":\"The error points to a plugin file \u2014 what do I do?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Update the plugin first (the developer may have fixed it), then deactivate it to confirm it's the cause. If you can't reach your dashboard, rename the plugin's folder via FTP to force-deactivate it, then rename it back after fixing or replacing it.\"}},\n    {\"@type\":\"Question\",\"name\":\"I fixed the file but still see the error \u2014 why?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Usually caching. A cached copy of the page can still show the warning after you've fixed it. Clear your site cache, server cache, and browser cache, then reload. If it persists, check for a BOM (save the file as UTF-8 without BOM) or another file with stray output.\"}}\n  ]\n}\n<\/script>\n\n\n\n<div style=\"max-width:760px; margin:32px auto; background:linear-gradient(135deg,#1A2238 0%,#F26C21 100%); border-radius:16px; padding:32px 28px; font-family:inherit; color:#fff; box-shadow:0 10px 30px rgba(242,108,33,.25);\">\n  <div style=\"display:flex; align-items:flex-start; gap:16px; flex-wrap:wrap;\">\n    <div style=\"flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; width:52px; height:52px; border-radius:12px; background:rgba(255,255,255,.18);\">\n      <svg width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"16 18 22 12 16 6\"><\/polyline><polyline points=\"8 6 2 12 8 18\"><\/polyline><\/svg>\n    <\/div>\n    <div style=\"flex:1 1 320px; min-width:260px;\">\n      <div style=\"font-weight:800; line-height:1.25; margin-bottom:8px;\">Hosting with the tools to fix things fast<\/div>\n      <p style=\"margin:0 0 18px; line-height:1.6; color:#FFE6D5;\">Editing a file over FTP, restoring a backup, clearing a cache \u2014 Copahost gives you an easy File Manager, one-click backups, and support that knows WordPress, so a stray space never costs you your afternoon.<\/p>\n      <a href=\"https:\/\/www.copahost.com\/web-hosting\/\" style=\"display:inline-flex; align-items:center; gap:8px; background:#fff; color:#F26C21; font-weight:700; text-decoration:none; padding:13px 26px; border-radius:10px; box-shadow:0 4px 12px rgba(0,0,0,.15);\">\n        See web hosting plans\n        <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#F26C21\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M5 12h14M13 6l6 6-6 6\"><\/path><\/svg>\n      <\/a>\n    <\/div>\n  <\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;Cannot modify header information &#8211; headers already sent by&#8221; looks intimidating but is one of the more readable WordPress errors: the message names the exact file and line where stray output began. Open that file (the one in &#8220;output started at,&#8221; not the core file at the end), remove the offending whitespace, blank line, or premature output \u2014 or update the plugin or theme responsible \u2014 and the warning clears. Removing the closing <code>?&gt;<\/code> from pure-PHP files and saving without a BOM prevents it from coming back. And as always, edit through FTP with a backup in hand, so a small fix never turns into a big problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The error &#8220;Warning: Cannot modify header information &#8211; headers already sent by&#8221; means a PHP script tried to send HTTP headers (for a redirect, cookie, or page setting) after content had already been sent to the browser. The usual cause is stray output \u2014 a blank space, line break, or text \u2014 before the headers, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5075,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[133],"tags":[],"class_list":["post-5074","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost<\/title>\n<meta name=\"description\" content=\"Cannot modify header information - headers already sent by&quot; means PHP output started before the headers. Learn to read the error and fix it fast.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost\" \/>\n<meta property=\"og:description\" content=\"Cannot modify header information - headers already sent by&quot; means PHP output started before the headers. Learn to read the error and fix it fast.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\" \/>\n<meta property=\"og:site_name\" content=\"Copahost\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-25T14:28:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-25T14:33:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1672\" \/>\n\t<meta property=\"og:image:height\" content=\"941\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Gustavo Gallas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gustavo Gallas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\"},\"author\":{\"name\":\"Gustavo Gallas\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246\"},\"headline\":\"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It\",\"datePublished\":\"2026-06-25T14:28:39+00:00\",\"dateModified\":\"2026-06-25T14:33:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\"},\"wordCount\":1697,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png\",\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\",\"name\":\"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png\",\"datePublished\":\"2026-06-25T14:28:39+00:00\",\"dateModified\":\"2026-06-25T14:33:13+00:00\",\"description\":\"Cannot modify header information - headers already sent by\\\" means PHP output started before the headers. Learn to read the error and fix it fast.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png\",\"width\":1672,\"height\":941,\"caption\":\"WordPress cannot modify header information headers already sent error\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.copahost.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"name\":\"Copahost\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.copahost.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\",\"name\":\"Copahost\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"width\":223,\"height\":40,\"caption\":\"Copahost\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246\",\"name\":\"Gustavo Gallas\",\"description\":\"Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development\u200b. Also have brewing skills.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/gustavo-gallas-107926196\/\"],\"url\":\"https:\/\/www.copahost.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost","description":"Cannot modify header information - headers already sent by\" means PHP output started before the headers. Learn to read the error and fix it fast.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/","og_locale":"en_US","og_type":"article","og_title":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost","og_description":"Cannot modify header information - headers already sent by\" means PHP output started before the headers. Learn to read the error and fix it fast.","og_url":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/","og_site_name":"Copahost","article_published_time":"2026-06-25T14:28:39+00:00","article_modified_time":"2026-06-25T14:33:13+00:00","og_image":[{"width":1672,"height":941,"url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png","type":"image\/png"}],"author":"Gustavo Gallas","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Gustavo Gallas","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#article","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/"},"author":{"name":"Gustavo Gallas","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246"},"headline":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It","datePublished":"2026-06-25T14:28:39+00:00","dateModified":"2026-06-25T14:33:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/"},"wordCount":1697,"commentCount":0,"publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/","url":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/","name":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It - Copahost","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png","datePublished":"2026-06-25T14:28:39+00:00","dateModified":"2026-06-25T14:33:13+00:00","description":"Cannot modify header information - headers already sent by\" means PHP output started before the headers. Learn to read the error and fix it fast.","breadcrumb":{"@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#primaryimage","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2026\/06\/headers-already-sent-cover.png","width":1672,"height":941,"caption":"WordPress cannot modify header information headers already sent error"},{"@type":"BreadcrumbList","@id":"https:\/\/www.copahost.com\/blog\/cannot-modify-header-information-headers-already-sent-by-how-to-fix-it\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.copahost.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Cannot Modify Header Information \u2014 Headers Already Sent By: How to Fix It"}]},{"@type":"WebSite","@id":"https:\/\/www.copahost.com\/blog\/#website","url":"https:\/\/www.copahost.com\/blog\/","name":"Copahost","description":"","publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.copahost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.copahost.com\/blog\/#organization","name":"Copahost","url":"https:\/\/www.copahost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","width":223,"height":40,"caption":"Copahost"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246","name":"Gustavo Gallas","description":"Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development\u200b. Also have brewing skills.","sameAs":["https:\/\/www.linkedin.com\/in\/gustavo-gallas-107926196\/"],"url":"https:\/\/www.copahost.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/5074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/comments?post=5074"}],"version-history":[{"count":2,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/5074\/revisions"}],"predecessor-version":[{"id":5078,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/5074\/revisions\/5078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/media\/5075"}],"wp:attachment":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/media?parent=5074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/categories?post=5074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/tags?post=5074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}