Getting 502 Bad Gateway (nginx) when script writes to DB ... (completely random)

January 4, 2018 1.2k views
Nginx PHP MariaDB Ubuntu 16.04

Hi,

I am running a PHP script (CPVlab) on a droplet and when I write something to the DB with it, chances are that I will randomly get a bad gateway 502 message from nginx ... With random I mean : at times it works, and then the next time it doesn't.
At the same time, if I'm logged into the shell through putty, it will tell me : network error : software caused connection abort

Below are some logs ... could it be a permissions issue ? That would be weird, as it works sometimes ...

Anyone have an idea ?

PHP Log seems to be in some loop ?

[05-Oct-2017 07:48:49] NOTICE: Terminating ...
[05-Oct-2017 07:48:49] NOTICE: exiting, bye-bye!
[05-Oct-2017 09:49:07] NOTICE: fpm is running, pid 1476
[05-Oct-2017 09:49:07] NOTICE: ready to handle connections
[05-Oct-2017 09:49:07] NOTICE: systemd monitor interval set to 10000ms
[05-Oct-2017 09:52:36] NOTICE: Terminating ...
[05-Oct-2017 09:52:36] NOTICE: exiting, bye-bye!
[05-Oct-2017 09:52:55] NOTICE: fpm is running, pid 1531
[05-Oct-2017 09:52:55] NOTICE: ready to handle connections
[05-Oct-2017 09:52:55] NOTICE: systemd monitor interval set to 10000ms
[04-Jan-2018 09:18:05] NOTICE: fpm is running, pid 1537
[04-Jan-2018 09:18:05] NOTICE: ready to handle connections
[04-Jan-2018 09:18:05] NOTICE: systemd monitor interval set to 10000ms
[04-Jan-2018 10:10:04] WARNING: [pool www] child 11314 exited on signal 11 (SIGSEGV - core dumped) after 6.989500 seconds from start
[04-Jan-2018 10:10:04] NOTICE: [pool www] child 11317 started

*NGINX error log - File permission issue ? It worked before though *

#1 /var/www/mydomain.com/htdocs/cron-wurfl.php(0): Browscap->updateCache()
#2 {main}
  thrown in /var/www/mydomain.com/htdocs/phpbrowscap/Browscap.php on line 0" while reading response header from upstream, client: 87.213.252.89, server: mydomain.com, request: "GET /cron-wurfl.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com"
2017/10/05 09:58:54 [error] 1757#0: *13 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught exception 'Exception' with message 'Could not write to "/var/www/mydomain.com/htdocs/phpbrowscap/BrowserCache/browscap.ini" (check the permissions of the current/old ini file).' in /var/www/mydomain.com/htdocs/phpbrowscap/Browscap.php:0
Stack trace:
#0 /var/www/mydomain.com/htdocs/phpbrowscap/Browscap.php(0): Browscap->_getRemoteIniFile('http://101secur...', '/var/www/forwar...')
#1 /var/www/mydomain.com/htdocs/cron-wurfl.php(0): Browscap->updateCache()
#2 {main}
  thrown in /var/www/mydomain.com/htdocs/phpbrowscap/Browscap.php on line 0" while reading response header from upstream, client: 87.213.252.89, server: mydomain.com, request: "GET /cron-wurfl.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com"
2018/01/04 10:10:04 [error] 1945#0: *55 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 87.213.252.89, server: mydomain.com, request: "POST /direct-and-landing-campaign.php?id=3 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com", referrer: "http://mydomain.com/direct-and-landing-campaign.php?id=3"

Be the first one to answer this question.