Warning: Cannot modify header information - headers already sent My log is cluttered with this message:

Warning: Cannot modify header information - headers already sent by (output started at /home/path/to/drupal/7/includes/common.inc:2681) in drupal_send_headers() (line 1216 of /home/path/to/drupal/7/includes/bootstrap.inc).


It occurrs only when someone types address to a non-existing comment like this:

http://example.com/comment/874


If the comment exists, or for any other address, there is no error. (I was deleting lots of spam comments recently and the bots keep coming back to read their own comments, that's why there is a lot of not found comments.)

Is there any means to get rid of this error? The only comment module I have is Comment Goodness and there isn't complaint on such error in the issue queue, so maybe it's something else. I checked all my custom module files and each of them starts with &lt;?php and there is no space or anything before this tag, and there is no closing tag. I have no idea what else to check.
In my own case, I've found that this was due to modules that attempt to return a 404 by mistakenly calling drupal_not_found() instead of returning the MENU_NOT_FOUND constant. This causes drupal_deliver_page() to be called twice in a single page request.

Views is the biggest culprit right now; see https://drupal.org/node/1414068 (comment #16) for a patch that resolves it. You should grep through your modules directory for "drupal_not_found" to find other modules with this problem.