WordPress Error: Warning: Cannot modify header information

Yesterday I was helping a reader solving his WordPress error, so I thought I might as well write an entry, just in case we all encounter this in the future. If you ever run across this error (or warning) in your WordPress with the message saying:

Warning: Cannot modify header information - headers already sent by (output started at //home/htdocs/wordpress/wp-config.php:1) in /home/htdocs/wordpress/wp-login.php on line 12

or something similar, chances are you have messed up your wp-config.php leaving some unnecessary spaces inside.

Solution

  1. Download your wp-config.php down via FTP (Edit directly if you have SSH access)
  2. Open wp-config with your favourite editor, and remove all spaces before "<?php" and after "?>"

    wordpress error

    wordpress error

  3. Upload and replace.

You are adviced to make backup of any files you edited.

WebsiteFacebookTwitterInstagramPinterestLinkedInGoogle+YoutubeRedditDribbbleBehanceGithubCodePenWhatsappEmail