I have a site running on aws But it stops working regularly. And once I restart PHP-fpm it starts working smoothly.
This is the error I am getting in error log when site throws 504 -
2308#2308: *3310 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 54.215.160.135, server: api.mysite.com, request: "POST /notfound HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock"
I tried solving this but unable to solve. I also tried re-installing PHP-FPM but not solved the problem.
here is my nginx conf file -
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
include fastcgi_params;
}
Also when I check status of FPM it shows -
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-01-04 04:23:13 UTC; 1h 52min ago
Docs: man:php-fpm7.2(8)
Main PID: 2314 (php-fpm7.2)
Status: "Processes active: 5, idle: 0, Requests: 1511, slow: 0, Traffic: 0req/sec"
Tasks: 6 (limit: 1152)
CGroup: /system.slice/php7.2-fpm.service
├─2314 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
├─3578 php-fpm: pool www
├─3579 php-fpm: pool www
├─3633 php-fpm: pool www
├─3784 php-fpm: pool www
└─3786 php-fpm: pool www
In pool.d/www.conf
user = nginx ##previously it was www-data
group = www-data
listen.owner = nginx ##previously it was www-data
listen.group = nginx ##previously it was www-data
listen.mode = 0660
listen = /run/php/php7.2-fpm.sock
How can I solve this issue?