Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
nginx + php5-fpm results in random 502 Bad Gateway #14187
Comments
|
Same problem here. I'll provide some logs that I found: 2015/02/13 07:56:42 [error] 6403#0: *12517 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: my.name.xx, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "my.name.xx" 2015/02/13 07:56:42 [crit] 6404#0: *3845 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: my.name.xx, request: "GET /status.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "my.name.xx" also there are 2015/02/13 09:03:39 [warn] 11283#0: *27 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: x.x.x.x, server: my.name.xx, request: "POST /index.php/apps/files/ajax/upload.php HTTP/1.1", host: "my.name.xx", referrer: "https://my.name.xx/index.php/apps/files/?dir=%2FMyDirectory" Those problems appears after Owncloud upgrade to 8, before nginx and php-fpm works well. Please take this as a critical issue. |
rockihack
commented
Feb 13, 2015
|
The socket file (unix:/var/run/php5-fpm.sock) is missing. Open your fastcgi pool config: Change listen to: Open your nginx site config: Comment out Don't forget to restart nginx and php5-fpm. |
|
Usin TCP socets are slightly slower performance then using sockets. This problem wasn't occurred in OC7 this appears after OC8 upgrade. |
Xsysstar
commented
Feb 14, 2015
|
I have the same problem but haven't tried the TCP-workaround. Contrary to @rockihack's assertion, the socket-file does not miss on my system when the 502 errors occur.
I think there might be something wrong with memcache/apc—I have not consciously enabled any sort of caching mechanism on my web service, by the way.
|
|
hmmm. interesting case. but to me this looks clearly like a problem in your os,webserver,php setup and not like an owncloud bug. |
karlitschek
closed this
Feb 14, 2015
Xsysstar
commented
Feb 14, 2015
|
@karlitschek I hope you pressed that "Close ticket" button by accident. Apparently, you know something to point to the cause of this problem and are currently preparing an post detailing your findings. Otherwise, please reopen the ticket. The upgrade to ownCloud 8 is the single change in our "os,webserver,php setup" that causes this problem to emerge. Undeniably, ownCloud is a trigger and that begs for investigation in collaboration with ownCloud-devs. After investigation, we'll be able to make statements about the cause and everyone will be happy. The "apc_store"-function (in ownCloud code!) is the one that consistently shows up in my slow-log (as I quoted). Thus, it seems that this function call causes php-fpm to deadlock/freeze. For now, I have bluntly disabled APCU in my PHP-FPM-configuration:
We'll know in a day if this works; the problem emerges quite regularly approximately every 12 hours. |
|
ok. i reopen this. but this still looks like a configuration issue. of course owncloud uses apc calls. but they should work fine if the environment is configured correctly. |
|
I will try to do some more debugging. But as I said earlier, this problem comes out after OC8 upgrade, so I assume there can not be problem in webserver conf... |
rockihack
commented
Feb 14, 2015
|
I'm running owncloud8 (fresh install) with nginx, php5-fpm and postgresql just fine... |
|
And you are using only TCP PHP connections intead of sockets? Can you post your nginx and php-fpm conf if possible, thanks a lot! |
rockihack
commented
Feb 14, 2015
|
Nope it runs with unix socket and I forgot to mention that it uses APCu. |
cyking
commented
Feb 15, 2015
|
I upgraded from 7.x to 8 now both my installations are getting 502 errors ever couple hours. Only thing changed was OC. Running Ubuntu 14.04 with nginx. |
laurivosandi
commented
Feb 15, 2015
|
Hello, switching from UNIX sockets to TCP socket seems to fix the issue but that's not a real solution to the problem as UNIX socket is the preferred way for communications in this case (nginx and php5-fpm in same machine). |
Xsysstar
commented
Feb 15, 2015
|
My earlier attempt (of butchering APCU) has not worked. I woke up this morning with error messages from clients that couldn't connect to ownCloud due to a 502 Bad Gateway-error. The nginx-log shows:
The contents of
In other words, some massive php-fpm crash/restart seems to have occurred around 06:27 (timing looks consistent with my earlier findings). My hypothesis is the regular respawning doesn't work: I have modified
We'll see if this works in a day or less. P.S. @karlitschek I notice this ticket has the 'closed' state, still. |
|
I tried also to set pm.max_requests = 0 but still nothing... |
Xsysstar
commented
Feb 16, 2015
|
Setting |
laurivosandi
commented
Feb 17, 2015
|
Hello, I just discovered that on Apache similar issues happen. Web server just stops responding. |
Xsysstar
commented
Feb 18, 2015
|
I am getting "Gateway Time-out" errors today when updating my calendar via CalDAV. This is truly odd. I wonder if there's a memory leak somewhere. Suppose some calendar update is requested by the client. ownCloud is using all sorts of resources to process the request but does not close them. With With @karlitschek Why is this ticket still closed? We need a developer in here. |
cyking
referenced this issue
Feb 19, 2015
Closed
reopen nginx + php5-fpm results in random 502 Bad Gateway #14187 #14360
cyking
commented
Feb 19, 2015
|
I am not familiar with the polite practice of how to request attention to this so I made a new issue... |
Xsysstar
commented
Feb 19, 2015
|
Apparently, a new ownCloud package for my Ubuntu server was released in the last few days. New and old version seem to be equal, though (8.0.0-5). We'll see if this makes any difference in a day or so. Today, before the update, I was still dealing with timeouts. @cyking Good call. |
dirkhusemann
commented
Feb 19, 2015
|
Tried pretty much everything described here, still getting 502 after a couple of hours (with "a couple of Hours" varying from 2 to almost 12). Please reopen! This bug renders owncloud unusable. |
LukasReschke
reopened this
Feb 19, 2015
s1lvester
commented
Feb 22, 2015
|
I can confirm this. after a few hours of running oc 8 and syncing files php5-fpm times out when using sockerts (php5-fpm.sock) on ubuntu 14.04
my other oc8 installation on debian stable works fine. so maybe its a problem with ubuntu-packages (either oc oder php5-fpm)... |
cyking
commented
Feb 23, 2015
|
I installed via the web installer as well as manually via tar with same results on ubuntu 14.04. I have never used the ubuntu deb package. |
StormCh
commented
Feb 25, 2015
|
Hi, it seems to be a problem caused by the owncloud client software. After updating to oc8 the clients ask/request the files stored on the server very often (with errors in my case). This tooks me 4 days to find out. After the owncloud client software only "synchronize" new and updated files - the problem was gone. |
Xsysstar
commented
Mar 3, 2015
|
@StormCh Can you elaborate what you mean with "only synchronize new and updated files"? I just downloaded and upgraded to the dev-version (ownCloud-1.8.0.4730beta1-setup.exe) of the ownCloud client. The problem persists. My local copies of ownCloud folders (I use a dozen separate folders) had been in sync since long before upgrading the server to ownCloud 8. I do notice something related, though. When I start up the Windows ownCloud client, about 4 sync folders are marked as "up-to-date" while the rest is waiting in a "pending synchronisation" state. Those eventually time-out. The ownCloud client user interface is very sluggish during this wait. Eventually, the ownCloud client establishes synchronization parity and all folders are marked "green" (perhaps due to my cron-jobbed I'll make a ticket in the mirall bug tracker referencing this one to ask for their insights. |
Xsysstar
referenced this issue
in owncloud/client
Mar 3, 2015
Closed
Bad Gateway or timeouts possibly related by mirall-activity (see core#14187) #2913
StormCh
commented
Mar 3, 2015
|
@Xsysstar "only synchronize new and updated files" - means: normal synchronisation. So the ownCloud Client Software only need to sync new and updated files. All other files are in sync. I do have 4gb of Data to sync and about 5.000 files in many folders. This constellation was working with oc7 and ownCloud Clients a long time |
Xsysstar
commented
Mar 4, 2015
|
On the other issue, I received more contribution from devs than in this ticket. I have also postulated a new theory: APC (the caching mechanism) might be out of memory. I need to confirm it yet, but feel free to help me to do so. For those who want to try a hotfix to this issue, would you mind trying disabling APC in your PHP-installation? If the problem does not occur then (good news!), the next step would be experiment with configuring APC to have higher memory limits. |
dirkhusemann
commented
Mar 4, 2015
|
@Xsysstar i tried disabling APC: no dice, same result :-( |
cyking
commented
Mar 4, 2015
|
I don't think it's a memory issue. I have 8GB of free ram on one of my servers and I still have to restart php5-fpm. |
Xsysstar
commented
Mar 4, 2015
cyking
commented
Mar 7, 2015
|
I upgraded to PHP 5.6 and the problem went away. How to upgrade from php v.5.5.9 to v.5.6https://www.digitalocean.com/community/questions/how-to-upgrade-from-php-v-5-5-9-to-v-5-6 I should also mention that prior to upgrading to the ppa, I pulled owncloud v8.0.1 branch and the issue still persisted. I'm still currently using owncloud v8.0.1 with php v5.6. I have not tested owncloud v8.0.0 with php v5.6 |
Xsysstar
commented
Mar 7, 2015
|
Thanks @cyking! I will wait a little bit upgrading (I am a bit reluctant to install random PPAs), but may do so if the problem persists. On my end, disabling APC does actually seem to have effect. I'll have to wait a bit more to be sure. Disabling APC(u)In
Then |
Xsysstar
commented
Mar 14, 2015
|
A week of a working ownCloud is better than half a day, but I encountered another 502 Bad Gateway-error just now. And, conform expectation, php5-fpm was dead.
I just "started" (instead of restarted) php5-fpm but that does not solve the problem, by the way. I have to restart php5-fpm after just starting it for nginx to kiss php5-fpm again. My hypothesis of locked resources could permit this behaviour. I do wonder what kind of (system-wide) resources php5-fpm/ownCloud uses that are not automatically disposed when it crashes? In particular: what resources are used by php5-fpm/ownCloud but even more so if APC is also enabled? Some kind of storage, or handle, or socket? Ideas/suggestions? P.S. Today is Pi-day and yesterday this ticket was a month old! Happy anniversary, everyone! How shall we celebrate and thank the ownCloud-devs? (lolcat-pictures eating cloud-shaped pie?) |
cyking
commented
Mar 15, 2015
|
I've never had apc enabled on my owncloud hosts. The only solution for me was to upgrade php via PPA. |
Xsysstar
commented
Mar 15, 2015
|
I suppose I will upgrade to PHP 5.6 as well (with APC enabled). I'll report back if the problem persists. |
PVince81
added
the
bug
label
Mar 17, 2015
|
I believe this was addressed in 8.0.2 by disabling buggy, versions of APCu <4.0.6 for anyone experiencing this issue, what version of owncloud and APCu do you have? |
|
Yes. I assume this is fixed. Let´s close it for now. We can always reopen if the problem still exists. |
karlitschek
closed this
Mar 17, 2015
Xsysstar
commented
Mar 17, 2015
|
@josh4trunks I used the Ubuntu trusty packages of PHP and any of its modules. It seems trusty contains a buggy php5-apcu version (4.0.2-2build1). My ownCloud-installation is of version 8.0.1. I followed @cyking's instructions for upgrading PHP, which (with APCu enabled) seems to indeed work (for now). |
bigbang55
commented
Apr 2, 2015
|
I probably have no business here, since I don't actually use Owncloud, but I just wanted to thank you guys for the insights and solution. I've been having this exact same problem for almost two weeks now, on a extremely busy website that I run with Ubuntu+Nginx+php-fpm. After several days of testing with no success, I arrived at this discussion and upgrading PHP from 5.5.9 to 5.6.7 (APC enable as well) did the trick. Wish I knew why, but anyway, thank you all again! |
fiatux
commented
Apr 14, 2015
|
any updates on this issue? i'm experiencing this on 5.5.23 on ubuntu trusty. @cyking is this the correct way to upgrade php5-fpm to 5.6 also as php-fpm? https://www.digitalocean.com/community/questions/how-to-upgrade-from-php-v-5-5-9-to-v-5-6 |
leeychee
referenced this issue
in jchaney/owncloud
Apr 15, 2015
Merged
dockerfile: update to 8.0 #10
cyking
commented
Apr 22, 2015
|
@fiatux Yes, for me this PPA works fine. "He is one of the Debian maintainers of the php5 package." |
thorleifjaocbsen
commented
Aug 14, 2015
|
I'm having this problem too, same error logs, trying to disable APC now as suggested above. next might be an upgrade but i'm not really willing to :-/ |
kamaroly
commented
Sep 18, 2015
|
service php5-fpm restart |
bobweston
commented
Sep 23, 2015
|
For what it's worth, I had this same issue after upgrading my server from ubuntu 12.04 to 14.04. Our devops setup is completely puppetized. The problem was I had forgotten to do a puppet provisioning run after upgrading the server. In vagrant, I just had to run vagrant provision [server_name] to get everything working again. |
bobweston
commented
Sep 23, 2015
|
One other point, if you google php5-fpm crashes, you'll see that this is a common problem (php5-fpm crashes which lead to 502 errors and the need to restart). One quick and dirty way to fixing it is to set up a root crontab that restarts php5-fpm hourly. sudo crontab -u root -e (This assumes you have sudo privileges) Then add 0 * * * * /usr/sbin/service php5-fpm restart > /dev/null 2>&1 Tips for a cleaner way of dealing with the problem can be found in this thread: |
donSchoe
commented
Oct 28, 2015
|
why is this still closed? is creating a cronjob which restarts fpm every hour just-in-case really a solution? i have the issue still with owncloud 8.2, nginx 1.8.0 and php 5.6.14. on archlinux with kernel 4.2.4-1. my current workarounds:
upgrading php is no option for me since i'm already on 5.6.x. this is a fresh installation of owncloud 8.2.x. maybe if these workarounds are desired behaviour, we should add them to the ngingx docs? |
donSchoe
commented
Oct 28, 2015
|
tl;dr all fixes of this thread applied = still bad gateway / timeout issues. please reopen @karlitschek restarting fpm seems not to fix this either. |
|
@donSchoe what version of php-apc do you have? from my perspective this isn't a bug with ownCloud but with the underlying dependencies which this project has no control of (its the operating systems jobs to make sure not to ship buggy versions). |
donSchoe
commented
Oct 28, 2015
|
@josh4trunks no apc installed. should I? extra/php-apcu 4.0.7-1 |
|
@donSchoe youll want to find out what is causing your issue, and file another bug for it either here or with the php project. have you identified if your php-fpm is crashing or if it's a connection issue between nginx and php-fpm? |
butonic
referenced this issue
in owncloud/client
Nov 12, 2015
Closed
[1.8.1] [Discovery] XML "Premature end of document." #3298
behdadk
commented
Dec 6, 2015
|
I'm facing the very same problem, so far I could identify why I'm getting segfault: debian kernel: [11031.822778] php5-fpm[9608]: segfault at 7ffc9c996fc0 ip 00007f926b456c1a sp 00007ffc9c996fb0 error 6 in libpcre.so.3.13.1[7f926b443000+6c000] |
tflidd
referenced this issue
in owncloud/client
Dec 18, 2015
Closed
[PHP-FPM] "Connection closed" in client, "(104: Connection reset by peer) while reading upstream" in server #4299
stratease
commented
Mar 4, 2016
|
I was having a very similar issue, albeit I'm not on Owncloud, this was one of the only threads I could find illustrating solutions that I hadn't already tried. And the php version upgrade @cyking mentioned worked for me. Error free for a few days now. Thanks! |
nprokopic
commented
Mar 14, 2016
|
I had this issue on Ubuntu 14.04 after updating packages, I was getting connect() to unix:/var/run/php5-fpm.sock failed No such file or directory) while connecting to upstream. What solved the problem for me was appending this two lines in
Here is the original StackOverflow answer that saved my day http://stackoverflow.com/a/26129470/4727982. |
fotastisch
commented
Apr 7, 2016
|
Hi! Lately, I have the same problem. The solution posted by nprokopic does not work for me... I'm using raspbian? Does anyone have ideas on how to solve it? THX!!! |
candidosales
commented
May 4, 2016
|
@nprokopic Thanks |
xiaooloong
commented
May 23, 2016
|
I have the same problem on my vps. (centos7 openresty1.9.7.4 php5.6.21) |
sertaconay
commented
May 27, 2016
|
Try "php -i" in command line and see if there is any error. I had a extension causes error then i disabled it. |
ghost
commented
May 27, 2016
|
https://www.scalescale.com/tips/nginx/502-bad-gateway-error-using-nginx/ -> No issue in ownCloud. If you need further help ask at a nginx support channel listed here: |
laomagege
commented
Jul 5, 2016
•
|
vim /etc/php/5.6/fpm/pool.d/www.conf
so either change the listen = /run/php7.0-fpm.sock
by the way, ensure the following 3 lines in the /etc/php/5.6/fpm/pool.d/www.conf are uncommitted, otherwise the permission error will show up in the /var/log/nginx/error.log
|
killzoms
commented
Aug 28, 2016
•
|
Just want to tell you guys a little thing that your not noticing. |
flowl
commented
Oct 5, 2016
|
Ownloud doesn't alter configuration... it's a problem caused by the Debian/Ubuntu php5-fpm package. The init.d script does not recreate and touch the socket correctly after reloading I think. |
unhuman
commented
May 28, 2017
|
I solved this after a PHP upgrade by simply deleting the .socket file and restarting services. It then worked just fine. File name is the same, size is 0, and permissions are the same, yet it made the difference. |
laurivosandi commentedFeb 13, 2015
Hello,
we just upgraded several machines to OwnCloud 8 and the result is that php5-fpm occasionally goes nuts and stops responding to nginx. There is nothing interesting in logs and we're running on Ubuntu 14.04 with default nginx and php5-fpm packages.