
How to Fix Cookies Are Blocked Due to Unexpected Output Error in WordPress

Yuhda Ibrahim
Development Consultant
October 15, 2025
4 min read
Introduction
You’re all set to log in to your WordPress dashboard, but instead of getting in smoothly, you’re hit with an error that says: “Cookies are blocked due to unexpected output.” Frustrating, right? If you’ve run into this message, you’re not alone. Many WordPress users face this problem when trying to sign in, and it can feel confusing—especially since cookies are essential for keeping you logged in and managing sessions.
The good news? This issue isn’t as scary as it sounds. It usually happens when something on your site (like a plugin, theme, or even an extra space in your code) sends unexpected data before WordPress can set cookies. While it can be a bit technical, the fixes are straightforward once you know where to look.

In this guide, we’ll break down what causes the “Cookies are blocked due to unexpected output” error in WordPress, and walk you through step-by-step solutions you can try—even if you’re not a developer.
What Causes the “Cookies Are Blocked Due to Unexpected Output” Error?
This error shows up when WordPress is unable to set or read cookies properly during login. Some common causes include:
- Extra spaces or lines in the wp-config.php or functions.php file.
- Plugin conflicts that output data before cookies are set.
- Theme issues or poorly coded scripts.
- Incorrect site or WordPress URL settings.
- Browser caching problems.
Essentially, anything that produces “unexpected output” before WordPress sends headers can trigger this error.
Clear Your Browser Cache and Cookies
Before diving into deeper fixes, start simple.
- Clear your browser’s cache and cookies.
- Try logging in with Incognito/Private Mode.
- Test another browser to see if the issue persists.
If the error only occurs in one browser, this quick step might fix the issue right away.
Check wp-config.php for Extra Spaces or Errors
The wp-config.php file is one of the most common culprits. Even an extra blank space before the <?php
opening tag or after the ?>
closing tag can cause unexpected output.
To fix this:
- Access your site files via FTP or your hosting File Manager.
- Open the
wp-config.php
file. - Remove any unnecessary spaces or blank lines before
<?php
or after?>
. - Save the file and try logging in again.
Tip: WordPress doesn’t actually need the closing ?>
tag in wp-config.php
, so you can safely remove it.
Disable Plugins to Rule Out Conflicts
If the error isn’t in your wp-config.php
, a plugin may be sending output too early.
Here’s how to test:
- Go to your site’s root folder →
/wp-content/plugins/
. - Temporarily rename the plugins folder to something like
plugins_old
. - Try logging in again.
- If the error disappears, one of your plugins is causing the problem.
- Rename the folder back, then disable plugins one by one until you find the culprit.
Updating or replacing the conflicting plugin should resolve the issue.
Switch to a Default Theme
Themes can also cause this error if they output data before WordPress sets cookies.
- Temporarily switch to a default theme like Twenty Twenty-Four.
- If the error goes away, your theme needs fixing.
Contact the theme developer for support, or check the functions.php
file for unnecessary whitespace or echo statements.
Verify WordPress and Site URL Settings
Sometimes, mismatched WordPress Address (URL) and Site Address (URL) settings can cause login cookie issues.
- Go to your WordPress Dashboard → Settings → General.
- Ensure both WordPress Address (URL) and Site Address (URL) are identical.
- Example: both should use either
https://yourdomain.com
orhttp://yourdomain.com
.
- Example: both should use either
Consistency here ensures cookies are set correctly.
Increase PHP Memory Limit
If your site is running out of resources, it may cause unexpected behavior. Increasing the PHP memory limit can sometimes fix cookie errors.
To do this, edit your wp-config.php
file and add:
define('WP_MEMORY_LIMIT', '256M');
This gives WordPress more breathing room to handle processes smoothly.
Debugging with WP_DEBUG
If you’re still stuck, turning on debugging may reveal the exact cause of the unexpected output.
In wp-config.php
, add or update this line:
define('WP_DEBUG', true);
This will display any warnings or errors that occur before headers are sent. Once you’ve identified and fixed the issue, don’t forget to set it back to false
for security reasons.
Contact Hosting Support
If none of the above solutions work, the issue may be server-related. Some hosting environments add extra output that interferes with WordPress cookies. Reach out to your hosting provider, explain the error, and ask them to review server logs for clues.
Conclusion
Running into the “Cookies are blocked due to unexpected output” error in WordPress can feel intimidating, but the fixes are usually straightforward. Start with easy steps like clearing your browser cache, then move on to checking wp-config.php
, disabling plugins, or switching themes.
Most of the time, the problem comes down to a small coding hiccup or plugin conflict that’s easy to resolve. And if you’re still stuck after trying the solutions above, your hosting support team can often pinpoint the issue quickly.
By addressing this error, you’ll not only regain access to your WordPress dashboard but also make your site more stable for the long run.