NextCloud 502s on install (Nginx)

Okay I had accidentally closed this tab so I apologise if this is short or I’m missing anything.

I just installed Nextcloud on my production DietPi installation. However, after rebooting as it had requested and navigating to, I get a 502 error from Nginx (my httpd of choice). I hadn’t done any configuration between installing Nextcloud and going to the page (just the reboot) so I’m wondering if it’s my existing Nginx configuration that might be causing issues.

It’s not directly integrated into nginx.conf (it’s loaded as an include in a separate file).


many thanks for your report. I did a small test an my RPi3B+ and changed default web server to nginx and installed NextCloud from dietpi-software catalogue. For me this is working fine and I can open NextCloud Login page without issues. I did not do any config changes. I just install NextCloud.

The last comment I don’t understand. What do you like to say?

It’s not directly integrated into nginx.conf (it’s loaded as an include in a separate file).

I was trying to portray that the extra config isn’t in the nginx.conf directly, instead parsed separately by include (as shown below).


http {

# Load old Eizen config
include /etc/nginx/nginx-eizen.conf;

        server_names_hash_bucket_size 64;
        charset utf-8;

        # + Nginx - To avoid 2MB upload error:
        client_max_body_size 2047M;

Still I don’t know what you trying to point out.

Nextcloud config for nginx is located at /etc/nginx/sites-dietpi/dietpi-nextcloud.conf and in general config files are spread over various directories and taken together by a couple of include

root@DietPi3:/etc/nginx# cat nginx.conf|grep include
        include /etc/nginx/modules-enabled/*.conf;
        include mime.types;
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

root@DietPi3:/etc/nginx# ls -al|grep sites
drwxr-xr-x  2 root root 4096 Apr 19 15:06 sites-available
drwxr-xr-x  2 root root 4096 Apr 19 15:06 sites-dietpi
drwxr-xr-x  2 root root 4096 Apr 19 15:01 sites-enabled

and you get a http 502, means bad gateway. do you access nextcloud directly via IP or some DDNS name?

My conf also contains these includes (along with the extra include), and the directory structure produced by ls -al|grep sites.

I have attempted both direct IP access and the fqdn assigned by the DNS server here (which matches the hostname of the machine); both produce the same result. Even tried curling it locally on the machine (also a Pi3b+) to no avail.

So you added something to the config files?

Correct. I had added the line include nginx-eizen.conf (and only this line) as I moved and adapted the old production site configuration to this machine.

For completeness, I commented out this line, reloaded nginx, and the problem is not resolved.

You restarted the whole system after you excluded the whole line? Just to be sure. :wink:

Confirmed. This resulted in the same issue.

what happen if you just enter http://your.ip/ Does it give the Bad Gateway message as well?

Usually a 502 Bad Gateway error means that the web server you’ve connected to is acting as a proxy for relaying information from another server, but it has gotten a bad response from that other server. Which is strange, as on standard setup nginx will not act as proxy. Or did you configure something like this?

anything visible on the nginx error.log file?

cat /var/log/nginx/error.log

IP and FQDN still produce the issue–

A revelation has been made! The error.log file gives me three copies of

2020/04/19 16:38:32 [crit] 1220#1220: *9 connect() to unix:/run/php/php7.3-fpm.sock failed (2: No such file or directory) while connecting to upstream, client:, server:, request: "GET /nextcloud/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.3-fpm.sock:", host: ""

So it is PHP that is broken?

hmm let’s have a look. On my system the request files are there. pls do

ls -la /run/php/
[ ~]# ls -la /run/php/
total 8
drwxr-xr-x  2 www-data www-data 100 Apr 19 16:37 .
drwxr-xr-x 23 root     root     680 Apr 19 16:38 ..
-rw-r--r--  1 root     root       4 Apr 19 16:37
srw-rw----  1 www-data www-data   0 Apr 19 16:37 php7.2-fpm.sock
-rw-r--r--  1 root     root       4 Apr 19 16:37
[ ~]#

It’s missing. How did this happen?

hmm looks like something wrong with your PHP7.3 installation. I found a similar issue on the web describing yours exactly

solution was to install php7.3-fpm package

apt install php7.3-fpm

package availability on your system could be checked like this

dpkg -l php7.3-fpm

and that the service is running like this

systemctl status php7.3-fpm

After doing some research of my own with this lead, it took me to this Github issue ( in which it seems to be an issue with php7.3-fpm itself. Adjusting the nginx.conf to use 7.2’s fpm makes NextCloud work as intended. Issue resolved!

        # Upstream to abstract back-end connection(s) for PHP
        upstream php {
+               server unix:/run/php/php7.2-fpm.sock;
-               server unix:/run/php/php7.3-fpm.sock;

It seems that this was the reason why only Nextcloud was broken, as in my include config I was defining fastcgi manually.

Thank you for the help!

yes that was the other option to point back to php7.2. anyway, did you tried to install php7.3-fpm??

I had tried using both apt install --reinstall and apt remove, then apt install, but neither of those resolved it either (it just wouldn’t regenerate the socket).

ok strange, just keep in mind that active support for php7.2 already ended and it will get security fixes only until end of this year. sooner or later you might need to switch to php7.3 :wink: