WordPress.org

Ready to get started?Download WordPress

Forums

Backend Errors:: Premature end of script headers (28 posts)

  1. Rhand
    Member
    Posted 3 years ago #

    On a live site I am working on they have been getting these errors when using the Dashboard:

    [Mon Mar 14 17:08:38 2011] [error] [client xx.xxx.xxx.xxx] Premature end of script headers: index.php
    [Mon Mar 14 17:21:15 2011] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: index.php
    [Mon Mar 14 17:21:35 2011] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: index.php
    [Mon Mar 14 17:33:11 2011] [error] [client xx.xx.xx.xx] Premature end of script headers: index.php
    [Mon Mar 14 18:01:44 2011] [error] [client xx.xx.xx.x] Premature end of script headers: edit-comments.php, referer: http://www.domain.com/wp-admin/edit-comments.php?comment_status=all
    [Mon Mar 14 18:09:27 2011] [error] [client xx.xx.xx.x] Premature end of script headers: edit-comments.php, referer: http://www.domain.com/wp-admin/edit-comments.php?comment_status=trash&deleted=20
    [Mon Mar 14 18:09:57 2011] [error] [client xx.xx.xx.x] Premature end of script headers: index-extra.php, referer: http://www.domain.com/wp-admin/index.php

    SOmetimes certain pages lead to 404s until I reload. Never had this before. Any ideas?

  2. Rhand
    Member
    Posted 3 years ago #

    Contacted the hoster to see if it is a server load issue to see what is going on and if they can help out?

  3. Rhand
    Member
    Posted 3 years ago #

    Hoster blocked loading certain pages partly because the site demanded more than the maximum server load. Will work on trying to optimize. If that does not do the trick I might have to move to a VPS.

  4. Rhand
    Member
    Posted 3 years ago #

    Turned on debugging and got:

    Notice: Undefined index: aiosp_enabled in domain.com/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766
    Notice: Undefined index: aiosp_enabled in domain.com/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php on line 766

    Is not big deal: http://wordpress.org/support/topic/plugin-all-in-one-seo-pack-the-plugin-doesnt-work-for-me-on-wp-30?replies=12

    These I am not certain of:

    Notice: Use of undefined constant ddsg_language - assumed 'ddsg_language' in domain.com/wp-content/plugins/sitemap-generator/sitemap-generator.php on line 44
    
    Notice: add_option was called with an argument that is deprecated since version 2.3 with no alternative available. in domain.com/wp-includes/functions.php on line 3323
    
    Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in domain.com/wp-includes/functions.php on line 3323
    
    Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in domain.com/wp-includes/functions.php on line 3237
    
    Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in domain.com/wp-includes/functions.php on line 3237
    
    Notice: Undefined index: showcase_middle in domain.com/wp-content/themes/parallelus-unite/theme_admin/includes/sidebars-metaboxes.php on line 102
    
    Notice: Undefined index: showcase_right in domain.com/wp-content/themes/parallelus-unite/theme_admin/includes/sidebars-metaboxes.php on line 112

    Not made u my mind on one of these notices being the cause though. Will do some theme/plugin checks..

    Error log still shows same errors:

    [Wed Mar 16 00:42:02 2011] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
    [Wed Mar 16 01:37:05 2011] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php, referer: http://domain.com2010/09/page-name/?rcommentid=458&rerror=incorrect-captcha-sol&rchash=00db746f90563a14c8be74d31a7be788#commentform
    [Wed Mar 16 01:42:17 2011] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: wp-cron.php
    [Wed Mar 16 02:37:31 2011] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
    [Wed Mar 16 03:09:55 2011] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: wp-cron.php
    [Wed Mar 16 03:18:19 2011] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
  5. Rhand
    Member
    Posted 3 years ago #

    Checking error log with and without plugins running:

    1. Akismet
    2. All in One SEO Pack
    3. Category Redirect
    4. Dagon Design Sitemap Generator
    5. Executable PHP widget
    6. Formidable
    7. Formidable Extension
    8. MailChimp Archives
    9. Maintenance Mode
    10. Mass Custom Fields Manager
    11. Morfeo Video Gallery
    12. My Page Order
    13. NextGEN Gallery
    14. Page Links To
    15. Quotes Collection
    16. RYO Category Visibility
    17. Shopp
    18. Shortcode Exec PHP
    19. The Events Calendar
    20. WordPress Importer
    21. WP-reCAPTCHA
    22. WP Super Cache

    Also wonder if any of these plugins are known to eat a lot of memory..

  6. Rhand
    Member
    Posted 3 years ago #

    On the sop page I have 55 queries. 0.940 seconds - 71 queries. 1.071 seconds CPU time depending on the page using this code:

    <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds

    Does not sound like a bad number. And on top of this, this does not help me narrow down the "Premature end of Header Scripts" not the backend 404s.

  7. Rhand
    Member
    Posted 3 years ago #

    Reading and following http://openinworld.com/2011/03/wordpress-shared-hosting-performance/ at the moment. Good tips there to lower CPU/Memory

    Update: Seems like this site uses a lot (with all 24 plugins running):

    Usage Sample: 49MB (19%)
    Peak Usage: 75.13MB (29%)
    All-Time: 49.19MB on 3/16/11 @ 5:13 am (admin_print_footer_scripts)
    Load Averages: 0.47 0.38 0.3
    WP Memory Limit: 32M
    PHP Memory Limit: 90

    But still it did not reach its PHP limit. Just 25% of it.
    I guess Dream Host does not appreciate it and that is why the procwatch script keeps on killing the loading of admin pages. Just don't follow why that is the case as the PHP limit has not been reached according to the TPC! Memory Usage plugin

    Update:

    Did some more loading of admin pages and had a 404 and update of TPC! data:

    Usage Sample: 49MB (19%)
        Peak Usage: 63.4MB (25%)
        All-Time: 53MB on 3/16/11 @ 5:15 am (shutdown)
        Load Averages: 0.36 0.35 0.31
        WP Memory Limit: 32M
        PHP Memory Limit: 90M

    Added:

    define('WP_MEMORY_LIMIT', '96M');

    to wp-config.php

    and now have:

    Usage Sample: 49MB (19%)
        Peak Usage: 63.4MB (25%)
        All-Time: 53MB on 3/16/11 @ 5:25 am (shutdown)
        Load Averages: 0.43 0.4 0.32
        WP Memory Limit: 96M
        PHP Memory Limit: 90M
  8. Rhand
    Member
    Posted 3 years ago #

    Found out the TPC Memory Usage plugin sends loads of update e-mails to the admin. Need to shut that down.

    Update:

    Cannot shut down notifications, but raised limit to 64 MB and using own email address now. Current stats:

    * Usage Sample: 49.46MB (19%)
    * Peak Usage: 75.54MB (30%)
    * All-Time: 53.39MB on 3/17/11 @ 3:02 am (shutdown)
    * Load Averages: 0.13 0.49 0.54
    * WP Memory Limit: 96M
    * PHP Memory Limit: 90M

    I wonder if shutdown means when the server blocked the loading and showed the 404 I got again..

  9. Rhand
    Member
    Posted 3 years ago #

    I think it is Shopp that is asking for a lot of memory. Not really using that many queries but using elements in the Shopp backend gets met at 48-50 MB. I think DH cuts the loading around 50 MB if it happens for a while and even perhaps around 45 MB when that amount of memory is used for a while. The posts with extra custom fields demand a lot of queries - 75 to 90 - too though so I am not quite certain yet. Too bad I cannot really leave without the custom fields nor Shopp.

  10. Rhand
    Member
    Posted 3 years ago #

    Closing this thread. Apparently the previous developer did not adjust wp-config.php and the database was still being loaded from the old location which caused the server to do more work to connect. So I do believe I will not get any more 404s now.

  11. Rhand
    Member
    Posted 3 years ago #

    Well, premature end of script errors still occur, even after I moved the database to the proper location and adjusted wp-config.php. Really lost why the setup is still demanding so much CPU ...

  12. James Revillini
    Member
    Posted 3 years ago #

    I've been getting the same problem, and I use Dreamhost as well. I'll post any significant findings.

  13. Rhand
    Member
    Posted 3 years ago #

    @ jrevillini Thanks. Looking forward to your findings!

  14. Nyhm
    Member
    Posted 3 years ago #

    I'm having similar issues. When this error occurs, I'm thrown out of the admin area, back to the site's base URL. Is this the common result for anyone else?

    In my particular case, I'm using Piwik (installed externally) with WP-Piwik plugin inserting Piwik's JavaScript tracking code. Even though there is no tracking on the admin pages, this problem only seems to happen when Piwik JS tracking is used on the site.

    If this is just a general hosting issue, then maybe Piwik causes excessive memory usage. Any further insight would be greatly appreciated.

    PS: I'm on Dreamhost, as well.

    UPDATE: I've just reproduced this error without the Piwik JS tracking code mentioned above. the WP-Piwik plugin is still active, showing Piwik graphs on the Dashboard. Therefore, this could be a general hosting issue (memory/processes) caused by Piwik. More testing soon...

  15. Rhand
    Member
    Posted 3 years ago #

    More testing soon...

    Hope you find out more. The site still has the same issue from time to time.

  16. Nyhm
    Member
    Posted 3 years ago #

    Testing report: I've tried two memory monitoring plugins: WordPress System Health and TPC! Memory Usage.

    I was able to trigger the bad behavior, resulting in this apache error log entry:

    [Thu Aug 11 11:21:46 2011] [error] [client xx.xx.xx.xx] Premature end of script headers: index.php, referer: https://example.com/wp-admin/

    (The referer varies depending on what link triggered the failure.)

    Unfortunately (well, fortunately, but no cause found):

    • No indication of unusual memory spikes (using about 35MB of 90MB max)
    • The (shared) server is under moderate/heavy load (load averages from 4-9 observed), but I cannot confirm that this triggers the problem.

    Piwik Note: I tried all of this with and without WP-Piwik. At this time, I cannot trigger the problem again (it was very reliable this morning). This leads me to believe that this is not based on a particular plugin/script, but more likely a general hosting issue (system utilization).

    That's about all I can do for now. If anyone else can diagnose further, I'm keen to get to the bottom of this bad behavior.

    Can anyone else suggest other ways to diagnose this type of failure?

  17. Nyhm
    Member
    Posted 3 years ago #

    I just learned that if any content (even whitespace) accidentally appears after a php file's closing tag (the final ?>), it can be sent to the browser (which actually makes perfect sense).

    This can cause the 'premature end of script header' error if such output ends up in the wrong place in the generated HTML.

    It is now considered best practice (by some, such as the Zend framework) to always leave out the final php closing tag (no ?> at the end of any php file). PHP interprets the end-of-file as the implicit close. This prevents extra text output after the closing tag.

    Notice that a new install of WordPress will have no closing tag at the end of wp-config.php, for example.

    It seems that any number of plugins/themes could have bogus output after the close tag, causing this exception when pages are loaded in specific cases.

    Can anyone with more PHP expertise recommend a way to diagnose/verify/address this failure?

  18. James Revillini
    Member
    Posted 3 years ago #

    @Nyhm (love the DW icon BTW - was that a Warlock?) I think you might be confusing 2 different types of errors. I DO support leaving the closing ?> off of the end of any pure PHP file, but the thing that I think it mostly affects is when you want to modify headers using the PHP header() function. If you have

    <?php
    
    // do nothing
    
    ?> <?php 
    
    header('Location:http://google.com'); 
    
    ?>

    It will throw an error that 'headers cannot be modified' because of 'script output at line xxx', which is caused by the space between the two script blocks. If the first script block was in an include file and it had whitespace at the end, it would still be a problem to include before the call to header().

    Could it be you mixed up the two, or are you saying that this condition can cause both types of errors? You may know something I don't.

  19. Nyhm
    Member
    Posted 3 years ago #

    @jrevillini Wizard (Warlock was the tougher variant).

    I see what you are saying about the gap in the php tags.

    Honestly, I'm just casting spells in the dark here, trying to get an excellent move...

    OK, sorry. I'm trying to figure out why I get Premature end of header errors all the time. I'm only Magician-level when it comes to PHP/Web development. I need some more experience to level up...

    Sorry again. In all seriouslessness, I'd appreciate any advice you/anyone can give regarding slaying this evil dragon lord of a bug (yeah, that was pretty bad).

  20. nelswadycki
    Member
    Posted 3 years ago #

    I'm having the same problem on several of my WP sites. Seems like it happens more with some than others. My educated guess is that it's related to the load since it seems to happen more often with my higher traffic sites. All are hosted on DreamHost with a single account.

    @Rhand - if you're still paying attention... How do I turn on debugging? Looks like it might be a good way to identify plugins that could cause the issue.

  21. James Revillini
    Member
    Posted 3 years ago #

    @nelswadycki - same here ... bunch of sites on one Dreamhost account. a lot of people who have this problem are on DH so we may want to take it to them. They have the throttle controls, so I would imagine they have the logs which might indicate where things are spiking and/or dying.

  22. Rhand
    Member
    Posted 3 years ago #

    @ nelswadycki Yeah still following this thread. Less issues now without the use of Shopp though. Add

    define('WP_DEBUG',true);  // Turn debugging ON

    to your wp-config.php to print errors in front end.

  23. Nyhm
    Member
    Posted 3 years ago #

    Thanks for the debug tip. I'm still seeing the premature end of script errors, too, but less often. I'm not sure what has changed, though.

    Is there a way to direct the WP debug to a log file?

  24. Rhand
    Member
    Posted 3 years ago #

    @ http://fuelyourcoding.com/simple-debugging-with-wordpress/ I found this cool snippet:

    define('WP_DEBUG_DISPLAY', false); // Turn forced display OFF
      define('WP_DEBUG_LOG',     true);  // Turn logging to wp-content/debug.log ON

    to store logs and hide the display. Did not know about these WP definitions. Very useful.

  25. Nyhm
    Member
    Posted 3 years ago #

    @Rhand, Thanks for the tip. I tried it, and it dumps so many PHP notices that I'd be lucky to stumble upon the culprit. Is that normal for WordPress?

  26. Rhand
    Member
    Posted 3 years ago #

    Normally a regular homepage should only show a few errors. Unless you have plugins that cause more that is.. Perhaps you can put the errors at a pastebin an add a link here so people can have a look.

  27. shamstarek
    Member
    Posted 2 years ago #

    change .htaccess file to htaccess and refresh

  28. wampdog29
    Member
    Posted 2 years ago #

    anyone ever find out what was wrong with your errors? I seem to be having this same issue.

    I've tried just about everything: plugins deactivated, removed, theme change, lowering memory usage, switching from FastCGI, pinging, tracert.

    I use GoDaddy and am pretty good with code, especially PHP. I receive the Premature end of script headers which either leads to the page displaying 500 internal server error, a page saying I don't have permissions, logging me out or a simple cannot load page.

    Mostly the 500 internal server error though and always a premature end of script headers index.php in my error log along with a timeout 120 seconds log.

Topic Closed

This topic has been closed to new replies.

About this Topic