Timeout problems

I’ve just migrated from “old style” VPS to the new VPS with SSD. The bad performance of the new VPS is another matter but I have some issues with Apache with its default configuration.

I’ve been running a small sized Xenforo forum on the VPS for past 5 years or so without much problems. Some admin operations failed but that could always be cured with temporary RAM bump.

Not anymore. My VPS has twice RAM than before with max utilization below 50% of that. The CPU load is also small. But any attempt to upload a new style ends with server errors. It’s either 500 Internal Server Error (with FastCGI) - with “Premature end of header” in the log, or Gateway Timeout (with normal CGI).

Those problems are probably related to some timeout values set in the Apache config which isn’t accessible for me.

Is there any way to fix this?

I am having the same exact issue.

Was using FastCGI with PHP 5.6 with my VPS instance. I have a script that runs for more than 2 minutes but I am getting the “Premature end of script headers: index.php” in my error.log file for my domain.

Switched to CGI with PHP 5.6 and now Gateway Time-out error in my browser after about 3 minutes of the code running.

I am also not using a ton of memory. Here are my phprc values I was testing with:

max_execution_time = 1500
memory_limit = 256M

I have also tried changing permissions via chmod for my files and directories, but this didn’t make a difference.

Did you find a solution to this?

Yes. One of the support representatives realized that my SQL database is in different data center than the VPS. When he moved database, everything started working okay again.

Thank you so much for the reply!! I have spent tons of hours trying to debug this and it is driving me nuts!

It really does sound like I am having the same issue you had. And have been through several DH support reps, but they haven’t mentioned that it could be this. I am going to be contacting them now with a link to your post and this thread. Will write back with what they say.

I’m having this exact problem with a wiki upgrade I’m trying to do. I get an Internal Server Error (Premature end of script headers: index.php) because MySQL is unbelievably slow, especially during business hours.

So far I’m kind of disappointed with Dreamhost’s VPS. It doesn’t seem to work very well. I put a support ticket in so hopefully that resolves things.

Even if the symptom “Premature end of script headers” is the same, the problem most likely lies somewhere else. Please, post on the forums enough details for people to help out.

DreamHost has quite a few articles that describe what you can do to make your sites faster and more responsive. Some of the techniques and tools suggested for WordPress here https://help.dreamhost.com/hc/en-us/articles/215300867-General-WordPress-optimization-techniques can be applied to other PHP software.

When you write on the forums, and when you file support tickets, the more details you share the more chances you have to receive useful comments. Here for example, specify if your site is running on VPS or shared hosting (from the forums we can’t guess what kind of product you’re using). Also, it helps to know what software you’re running on that server (is there only one wiki? one mysql server? how many databases? PHP/python/ruby/java?) Instead of saying ‘mysql is slow’ give precise details and metrics, like: “with 20 active users on my site I notice that pages take an average of 25 seconds to load as measured by pingdom.” or something similar, something we can work with.

Otherwise your message will likely be ignored on the forums because it requires too much work for people to respond. DreamHost tech support will still respond, but will ask you more questions which will just make the ticket resolution take longer. Give more details in advance, save yourself time.


Do you have Dreamhost Mysql VPS or just Dreamhost VPS? If its just VPS, then you are still on a shared Mysql server.

I’m also curious to see if this was b/c of a MySQL and VPS being in different data centers. We’ve gotten smarter about that but there are still some that fall through the cracks.

So after several emails with DreamHost support people, I finally got this from one of them:

Thanks for contacting DreamHost. The FastCGI timeout is set to 120
seconds or two minutes. I actually have a bug open with our tech ops team
to provide some sort of option to allow customers to increase the timeout
limit, at least on a VPS, but it is still being talked about so nothings
close to being pushed out yet. I hate to say it but if you really need to
get this script running right away you may want to check out DreamCompute
where you can run pretty much whatever like and have complete root

Please feel free to contact us if you have any additional questions.

John R

I am not sure if any progress has been made internally with DreamHost in terms of support for being able to change the FastCGI timeout duration with a phprc file and VPS instances. I didn’t check back as I found a solution through different/unrelated means.

My solution was to convert my PHP code to a scheduled cron. PHP can run for an unlimited time period if it is run through the command-line or as a cron job. – At least with VPS instances.