504 Gateway Timeout after 120 seconds - php

My script sometimes takes more than 2 minutes and I am getting "504 Gateway Timeout Error" sometimes.
Following are the php server settings
max_execution_time 6000 (Local), 120 (Master)
max_input_time 120
memory_limit -1
I also tried using set_time_limit(0) but getting same error.
I also tried creating a php.ini at root directory with max_input_time=-1 but it is not updating
When I check in console Network section, the script timeouts after 1.1 minutes giving 504 gateway timeout error.
I checked the phpinfo(), Server type is fastCGI. On my local system (wamp) the script runs perfect. On local Server type is apache mod_php. It can be issue?
Please guide me how I can solve this issue.
Any help will be appreciated.

Related

Error 400: Bad Request, Your browser sent a request that this server could not understand

My website paroject is written with laravel framework and it configured with apache web server.
Some of requests in every pages get 400 error randomly with this message "Your browser sent a request that this server could not understand."
I read some articles in about that and I think that's issue related to resources config, so
I increased below variables in php.ini:
- memory_limit
- post_max_size
- upload_max_filesize
And I increased LimitRequestFieldSize in httpd.
But it's not worked for my issue.
Can anyone help me?
What can I do?
Any configs or any work?
What is my problem and how can I solve this issue.

Wordpress/Godaddy - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

I have followed most of the questions here, tried changing memory_limit, upload_max_filesize, post_max_size, max_execution_time, max_input_time, through .htaccess and php.ini file, but I'm still getting the same error.
Upon asking Godaddy support they are simply giving a scripted response. Stating that there is a problem with your plugins, you should deactivate and see.
Currently, GoDaddy support suggested adding the following configuration in php.ini and deactivate the plugins and it will resolve.
memory_limit 5000M
upload_max_filesize 3000M
post_max_size 3000M
max_execution_time 3000
max_input_time 3000
But, this error is been from the time of a fresh WordPress installation. So, will deactivating all the plugins lead to resolutions?. Any suggestions??
Because of this, I'm getting connection timeouts and unable to take a backup through admin.
Also, I'm on shared hosting. Site - 247btl.com
After a lot of playing around with php settings, this error was solved with the following PHP settings:
max_execution_time = 30
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
upload_max_size = 32M
I believe the problem was due to max_execution_time settings. Most of the guides suggested to increase it to 1000 along with increasing memory_limit, but that would lead to long load time. Tried it on a hostinger hosted website as well and it seems to work very well.
try to update your WordPress to the latest version if not already done.
Then if the problem is still there, contact hosting company and ask the hosting support team check following
1. your server are running latest version of PHP and the cURL library.
increase the Server Memory Limits settings.
The cURL error can be a dns related issue. Your hosting company might need to switch dns configuration to OpenDNS : https://www.howtogeek.com/164981/how-to-switch-to-opendns-or-google-dns-to-speed-up-web-browsing/
Ask your host if there is some limitation with wp-cron, or if loopback is disabled.
Ask your host if there a firewall or security modules (e.g. mod_security ) that could block the outgoing cURL requests.
You can also install the Query Monitor plugin and check the status of the HTTP API Calls in the admin page where the error is displayed.
In my case this was caused by the plugin "Contact Form by BestWebSoft".
If you find yourself in the same situation you have to disable the plugin one by one and refresh the page /wp-admin/site-health.php to check if the error is still there.
As explained here Getting "An active PHP session was detected" critical warning in wordpress this is due to a plugin badly developed.
Be aware that this issue can be caused by the use of the php session_start function. We had an issue where a developer had written the following.
add_action('init', function ()
{
if (!session_id()) { session_start(); }
});
This will kill the loopback and also disrupt REST API communications. This results in the cURL error 28 mentioned above. Sometimes it is not a complicated reason for the failure.
For Hostinger go to your Hosting Dashboard, then open PHP configuration option from Advanced menu(see screenshot below)-
After that goto PHP Options tab(see screenshot below)-
Then, Scroll down and change the MAX Execution value to 300(see screenshot below). Here 300 = 5 minutes. And after changing the value save these settings and this problem will get solved.

mod_fcgid read data timeout - Premature end of script headers

The websites on one of my Plesk users can't be accessed. The server reports a 500 Internal server error, the error_log for that user shows a bunch of
[warn] mod_fcgid: read data timeout in 60 seconds
[error] Premature end of script headers: index.php
The DocumentRoot contains a normal WordPress installation. Other sites running the same WP version, using the same DB server and PHP+Extensions run fine. A <?php phpinfo(); ?> runs fine as well. Calling php index.php from cli returns the webpage, but is a bit too slow for an idle Xeon E5-2620 Server w/ 64GB RAM
Are there any known Problems? How can I debug further?
Some more system info:
PHP 5.6.24 (tried 5.4 as well)
Plesk 12.5.30
EDIT: The Problem occurs intermittently. Right now, no 500 Error is returned, site loads fine (a bit slow). I increased memory_limit, just to be sure it isn't a config limitation
You can try to increase FcgidIOTimeout as described here https://kb.plesk.com/en/121251
Since Plesk 11.5, "FcgidIOTimeout" parameter is set to the same value as max_execution_time php parameter in domain's PHP settings
Also you can try any of PHP-FPM handler instead of FastCGI, because of mod_fcgid has a lot of internal performance limitations which can't be avoided.
The problem was caused by a rogue file_get_contents in some scripts.
I looked through the error log for the 1st appearance of the error message, and found a file created exactly when the error message first appeared - only 2 years earlier...
WordPress Site hacked? Suspicious PHP file
So I removed the malware ( detailed write-up at https://talk.plesk.com/threads/debugging-premature-end-of-script-headers.338956/ ), rebooted the Server and the error is now gone.
Technical detail: The error turned up because the Server distributing the malware is offline. file_get_contents("http..." timed out, the local script failed and returned the error message.

Magento: Getting 500 internal server error when creating invoices

I'm facing a big problem with my current Magento Shop. When I create an invoice through the backend I'm getting an 500 internal server error (after a long loading process). The server logs dont show anything, I looked into /var/log/apache2/error.log and theres nothing related. The error didnt show up on my dev machine, but since I moved the shop to our live server it occurs all the time.
What I tried so far:
Checked the file and folder permissions
Enabled Mage::setIsDeveloperMode(true); and ini_set('display_errors', 1);
Still no errors or logs
Deleted local.xml and generated a new one
Increased memory limit
Increased max execution time
Cleared cache
Checked .htaccess file, everything seems fine
Ran a script to check if everything matches the Magento requirements
This is starting to keep my busy for a couple of days now... and I dont know where to start, because the server doesnt even output an error in the logs. How can I force the server to log the error in the according file?
Do you have any other ideas what I can try to get rid of the error?
Attached also my php.ini file, maybe that helps.
PHP.ini http://pastebin.com/9BWQRHTu
PHP Version and OS: PHP Version 5.3.2-1ubuntu4.21
Env: Virtual Private Server
Increase memory_limit from 128M to 256M or 512M.
Clear browser cache and cookies. Do you encounter the same "500 server error" in other browser?
You said the loading process is long - measure the exact time couple of times and if the time is the same, which is set in php.ini, increase the max_execution_time
Find why is it taking so long to create an invoice using a debugger - most probably some module you have installed has a problem, like infinite loop, or it might trigger an action, which takes a lot of time, for example, reindexes everything each time. Creating an invoice shouldn't take so long and it is a problem in code - not in server settings probably.
I looked into the wrong error_log file, as I'm using Plesk the correct error_log file was located in /var/www/vhosts/xxx.com/statistics/logs/ and not in /var/log/apache2/
The error in there was
[Mon Nov 04 14:37:13 2013] [warn] [client xxx] mod_fcgid: read data timeout in 45 seconds, referer
This lead me to the fcgid.conf (etc/apache2/mods-available/fcgid.conf) where I had to increase the following values:
FcgidIdleTimeout 3600
FcgidProcessLifeTime 7200
FcgidMaxProcesses 64
FcgidMaxProcessesPerClass 8
FcgidMinProcessesPerClass 0
FcgidConnectTimeout 300
FcgidIOTimeout 180
FcgidInitialEnv RAILS_ENV production
FcgidIdleScanInterval 10

PHP post max size capped to 20M regardless php.ini settings

I have a debian squeeze server with Plesk Panel 11, apache and PHP 5.3.3
I want to increase maximum upload file size but when I try to upload more than 20M, in a single or multiple files, I receive the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
This is my settings:
memory_limit = 128M
max_execution_time = 3600
max_input_time = 3600
upload_max_filesize = 100M
post_max_size = 100M
and also
suhosin.memory_limit=0
suhosin.post.max_value_length=1000000
My apache error log does not contain any relevant reference to the error.
What could cause this 20M cap ?
I tryed a simple page with just a form with one file of 21M in test.php and test.html
The pure html form is submitted successfully. The same HTML code in test.php is not. Hence it must be some problem with PHP and not apache or the server.
I disabled all php extension and removed .htaccess without success.
I also tryed to post data locally from the server command line with curl but I got the same error.
Could be a bug of my PHP version ? Upgrading means to go from squeeze to wheezy, and since it's a production server I can't do this so easily
Did you happen to restart Apache?
/etc/init.d/apache2 restart
Once you do that it should work unless you are setting a file size limit in your PHP code.
Finally after many hours of trial and errors I found the solution!
It was the line
MaxRe­ques­tLen
in the file
/usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php
which is in effect only if PHP is loaded via fastCGI!!!

Categories