I'm running Apache2 and PHP5 on a dedicated VPS.
I have a script that should finish anywhere from 20-50 seconds. It works just fine, but if it takes over 30 seconds due to the rows it selected, it instantly kills the script and says:
"Service Unavailable - The service is temporarily unavailable. Please try again later."
I have max_execution_time=60, max_input_time=60 and memory_limit=256M in my php.ini.
In apache2.conf, I have Timeout=300.
In the script itself, I'm also using set_time_limit(0);
ignore_user_abort(true);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
No matter what I change the script dies anytime the loading takes over 30.00 seconds and nothing is appearing in any of my logs.
Any suggestions on what other settings to try?
This script is for internal use only and will eventually be running from command line, but I prefer to debug/test from the browser.
The error you listed: "Service Unavailable - The service is temporarily unavailable. Please try again later." doesn't sound like a 500 response, it sounds like a 503. Are you sure you are getting back a 500? The causes for a 503 would be different.
An internal server error. Check that all your directives are correct. If you have an .htaccess file, make sure you don't have any typos. Other than that, you can debug your script. You maybe changing a setting that triggers the error or conflicts with something else on the server.
Do you have Mod_Security or php-suhosin installed? Those might interfere with the default configurations.
Related
/*Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Additionally, a 503 Service Unavailable error was encountered while trying to use an Error Document to handle the request.
*/
I tried set_time_limit(0);
But still doesn't work.
Quite possible your running out of memory, causing php/apache to crash.
Check what its currently set to, then if you have enough resources update it in php.ini
Turn on error_reporting and i think it is the Memory_limit
i seem to have figured out the problem the System was on a shared host Server causing the memory limit to fail
Im running a long php script which handles large amounts of data.
The problem is that the script suddenly stops and no exception is thrown or could be found on the error_log.
I have set the display_errors and the error_logging to 1 in the .ini config file.
Few more details:
1) The scripts executes the 'file_get_contents' function for many times.
2) The scripts contains recursion when the file_get_contents fails.
Any help would be appriciated.
It might have hit the max execution time.
set_time_limit(0); // to increase the timelimit to infinity
Error loging configs are different depending on your hosting environment. I'd first verify that you're editing the right php.ini file. Take a look at your phpinfo output and make sure that those params are indeed set and check the path/file for where errors are being logged to. Sometimes it goes to the apache error log, other times it can be sent to a dedicated php log. Are you able to get any error output if you purposefully create a syntax error? You might also consider looking in your syslog to see if there's anything there.
We are running Drupal 5.x on Nginx with php-fastcgi.
Things were working fine for a while. All of a sudden, we (users) are running into 502 Bad Gateway error.
Restarting PHP-cgi, nginx.. rebooting machine etc did not help.
Did anyone else run into this type of issue? What are the possible suspects?
Today I was getting “502 Bad Gateway” on a CI project , after digging into the problem I found out it is a problem of nginx fastcgi buffers , here is how to fix it :
open /etc/nginx/nginx.conf
add the following lines into http section :
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
502 errors are usually caused when PHP freaks out for some reason. The first thing you should do is check all of your logfiles. That includes system stuff in /var/log/ and the nginx logs.
If you haven't made any recent changes and the problem just started happening for no apparent reason, PHP may be running out of memory. I know when it happens as an Apache module it gives a blank screen--wouldn't be surprised if a 502 error happened under nginx and the FastCGI interface. That's easy to fix by putting ini_set('memory_limit', '256M') into your index.php and see if that fixes the problem.
Also, can you load stand alone PHP files that don't involve Drupal? Put putting <?php phpinfo(); ?> into a file called info.php and try hitting that and see what happens.
Good luck!
I got this error as well and I eventually disable all modules (non-core) and enable them one by one to see what caused the error.
Here's a easy way to disable all non-core modules.
If the problem just started.. Read above.. if the server is new just setup, try this command to see if it's even listening on it's port
netstat -lpn | grep ":9000"
If course you could have setup fast-cgi to work on a different port, so just replace the port 9000 in that statement with what ever port you're looking for.. If nothing continues to show up, likely nothing is listening on that port and you need to fix that problem first.
If you have firePHP disable it.
Big headers causes problems while nginx comunication with php
Usually when I have come across this it has been a fatal error in PHP somewhere. Have a look at your PHP-cgi log to see if it is in there. There should be something in the nginx log like this: 104: Connection reset by peer. Depending on your setup this (sorry, link dead) might help but if you're using php-fpm it won't.
increase your memory limit and it will be fixed. ini_set('memory_limit', '256M');
It is because you probably upgraded to PHP 5.5 and therefore you now are using opcode cache which you may have enabled twice. That is check php.ini and also opcache.ini.
I'm trying to run a PHP script which has pg_connect($connection_string) and it just crashes my PHP script. I'm running it off of xampp on my computer, here are some facts:
If I put exit("test"); immediately above the pg_connect statement, it successfully displays the word "test" and terminates the script, so I know that my installation of xampp is working.
Using phpinfo() I can see that the postgresql extension is indeed loaded.
I can connect to the database server from pgadmin, so it's not a firewall issue or anything like that.
If I remove this exit statement, the pg_connect statement just hangs. There is no warning displayed or logged, and it never even gets past the function call. I even have:
$db_crm = pg_connect($connection_str);
if (!$db_crm) die("connection failed");
And "connection failed" is never even displayed. My browser just shows "this page cannot be displayed",after timing out.
What in the world could be causing this?
It's doubtful that the call is crashing PHP. More likely is that for some reason, the call is hanging for some reason and PHP's max execution time is being exceeded. You can try extending the time limit before making the pg_connect() call to see if it eventually comes back with something.
Check the Apache error logs
Check the php error logs
Make sure you have logging enabled in your Postgres config file.
In your config, set
log_min_error_statement (DEBUG5)
to grab everything possible.
Check the postgres error logs
Here it is guys:
I have no reason why, but adding sslmode=disable to the end of my connection string made it work. What reason would it have to crash? I am on a windows machine and phpinfo() says OpenSSL is enabled..
This sounds really stupid, but is your server running under SSL? I've had problems where a server will try to authenticate to ssl and hang indefinitely, trying to connect to a non-existent port.
sslmode=disable did the trick for me. To disable ssl in postgres-config ( ssl = false ) also worked.
For me, the Apache logs revealed that PHP was not finding the pg_connect() function, even though php-postgresql was installed. Restarting Apache fixed this, i.e.
sudo service httpd restart
I have a Drupal site on a shared web host, and it's getting a lot of connection errors. It's the first time I have seen so many connection timeout errors on a server. I'm thinking it's something in the configuration settings. Non-drupal parts of the site are not giving as many connection errors.
Since this hosting provider doesn't give me access to the php.ini file, I put one at my docroot to modify the lines that I thought would be causing this:
memory_limit = 128M
max_execution_time = 259200
set_time_limit = 30000
But it didn't work. There is no improvement in the frequency of the timeout errors. Does anyone have any other ideas about this type of error?
Thanks.
You can control the time limit on a script while your script is running. Add a called to set_time_limit near the top of your PHP pages to see if it helps.
Ideally you need to figure out what you actual limits are as defined by your host. A call to phpinfo() somewhere will let you see all the config settings that your server has in place.