Dreamhost HTTP error WordPress media upload and library

Spent the weekend troubleshooting a website error on Dreamhost with the Shared Hosting Plan.

Symptoms

  • Media files (pictures) larger than 2mb were spontaneously disappearing from the media library.

  • When uploading, large files would get the vague “HTTP error” in WordPress.

  • The thumbnail would be blank, and you couldn’t see the picture if you edited it.

  • The browser error console (right-click the page and Inspect Element) showed async-upload.php terminating with a 404 error.

  • The error log in the website itself (use SFTP to browse the /logs/ directory and open the error.log)  says “Premature end of script headers errors for async-upload.php”

  • It gets worse over time.

  • Performing the standard fixes in php.ini , or phprc.ini , or .htaccess does not fix the media library at all.

 

Verdict

Turns out, Dreamhost Shared Hosting has an automatic job that kills processes taking too much memory.   Check the link for more information.   When I saw this, I changed my memory limits lower (to 64M) and killed the php process to restart it, which didn’t make an obvious difference to me, but did reduce memory usage.

Going forward

I am carefully managing the picture sizes on my hosted websites now, with a goal of using images with (approximately) 1600×1000 resolution, or sub-200k size.  These images look great on a computer screen and seem to stay well within the Dreamhost memory limits.  So far I haven’t had any issues since making this chance.  The trickiest part is finding a user-friendly way to compress the images, especially when customers are authoring content.