# NextCloud 502s on install (Nginx)

**URL:** <https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020>\
**Category:** Troubleshooting\
**Created:** [19 April 2020 00:12 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020 "2020-04-19T00:12:21Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 00:12 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/1 "2020-04-19T00:12:21Z")

</div>

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 [http://this.is.an.ip/nextcloud](http://this.is.an.ip/nextcloud), 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).

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [19 April 2020 13:18 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/2 "2020-04-19T13:18:30Z")

</div>

Hi,

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).

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 16:52 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/3 "2020-04-19T16:52:51Z")

</div>

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

```nohighlight
...

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: https://github.com/MichaIng/DietPi/issues/546
        client_max_body_size 2047M;
        
...

```

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [19 April 2020 18:39 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/4 "2020-04-19T18:39:46Z")

</div>

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

```nohighlight
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/*;

```

```nohighlight
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?

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 19:20 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/5 "2020-04-19T19:20:36Z")

</div>

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

> [@](#):
>
> and you get a http 502, means bad gateway. do you access nextcloud directly via IP or some DDNS name?

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.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [19 April 2020 19:25 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/6 "2020-04-19T19:25:21Z")

</div>

So you added something to the config files?

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 19:35 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/7 "2020-04-19T19:35:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [19 April 2020 19:39 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/8 "2020-04-19T19:39:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 22:51 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/9 "2020-04-19T22:51:11Z")

</div>

Confirmed. This resulted in the same issue.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [19 April 2020 23:08 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/10 "2020-04-19T23:08:42Z")

</div>

what happen if you just enter [http://your.ip/](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?

```nohighlight
cat /var/log/nginx/error.log

```

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [19 April 2020 23:40 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/11 "2020-04-19T23:40:02Z")

</div>

IP and FQDN still produce the issue–

> [@](#):
>
> anything visible on the nginx error.log file?
> 
> ```plaintext
> cat /var/log/nginx/error.log
> 
> ```

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

```plaintext
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: 10.0.0.4, server: brooklyn.home.n.burneset.ga, request: "GET /nextcloud/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.3-fpm.sock:", host: "10.0.0.205"

```

So it is PHP that is broken?

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [20 April 2020 08:17 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/12 "2020-04-20T08:17:12Z")

</div>

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

```nohighlight
ls -la /run/php/

```

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [20 April 2020 22:07 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/13 "2020-04-20T22:07:21Z")

</div>

```nohighlight
[root@brooklyn.home.n.burneset.ga ~]# 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 php7.2-fpm.pid
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 php7.3-fpm.pid
[root@brooklyn.home.n.burneset.ga ~]#

```

It’s missing. How did this happen?

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [20 April 2020 22:22 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/14 "2020-04-20T22:22:50Z")

</div>

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

[https://superuser.com/questions/1456615/php7-3-doesnt-appear-on-run-php](https://superuser.com/questions/1456615/php7-3-doesnt-appear-on-run-php)

solution was to install php7.3-fpm package

```nohighlight
apt install php7.3-fpm

```

package availability on your system could be checked like this

```nohighlight
dpkg -l php7.3-fpm

```

and that the service is running like this

```nohighlight
systemctl status php7.3-fpm

```

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [20 April 2020 22:57 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/15 "2020-04-20T22:57:46Z")

</div>

After doing some research of my own with this lead, it took me to this Github issue ([https://github.com/laravel/homestead/issues/1031](https://github.com/laravel/homestead/issues/1031)) 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!

```nohighlight
        # 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!

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [20 April 2020 23:02 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/16 "2020-04-20T23:02:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Doq](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Doq](https://dietpi.com/forum/u/Doq)\
**Post date:** [20 April 2020 23:04 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/17 "2020-04-20T23:04:14Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [20 April 2020 23:07 UTC](https://dietpi.com/forum/t/nextcloud-502s-on-install-nginx/4020/18 "2020-04-20T23:07:57Z")

</div>

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 😉

[https://www.php.net/supported-versions.php](https://www.php.net/supported-versions.php)
