Ubuntu 20.04 install "502 Bad Gateway"

I’ve tried twice now, virgin installs, following the install instructions for Ubuntu 20.04 but I get the same result both times. I am certain I didn’t make any mistakes.


2020/09/18 00:39:52 [crit] 19595#19595: *1 connect() to unix:/run/php7.4-fpm-librenms.sock failed (2: No such file or directory) while connecting to upstream, client:, server: librenms, request: “GET /install HTTP/1.1”, upstream: “fastcgi://unix:/run/php7.4-fpm-librenms.sock:”, host: “librenms”

[email protected]:/var/run/php# ls -l
total 4
srw-rw---- 1 www-data www-data 0 Sep 18 00:37 php7.4-fpm-librenms.sock
-rw-r–r-- 1 root root 5 Sep 18 00:37 php7.4-fpm.pid
srw-rw---- 1 www-data www-data 0 Sep 18 00:37 php7.4-fpm.sock
lrwxrwxrwx 1 root root 30 Sep 18 00:21 php-fpm.sock -> /etc/alternatives/php-fpm.sock

(commented lines removed for brevity)

user = librenms
group = librenms

listen = /run/php/php7.4-fpm-librenms.sock

listen.owner = www-data
listen.group = www-data

[email protected]:~$ ./validate.php

Component Version
LibreNMS 1.67-33-gd559ffa9e
DB Schema Not Connected (0)
PHP 7.4.3
Python 3.8.2
RRDTool 1.7.2


[OK] Composer Version: 1.10.13
[OK] Dependencies up-to-date.
Could not connect to database, check logs/librenms.log.

Database error is because I can’t get to the /install to populate the database. The database exists as does the mysql user.

I appreciate your help.


In the error, the socket file is different then what is in your php-fpm config:
connect() to unix:/run/php7.4-fpm-librenms.sock failed
is not the same as:
listen = /run/php/php7.4-fpm-librenms.sock
(note the extra /php/ directory)

1 Like

Thanks Edwin. That was it. The annoying thing is that I did notice that but after a 12 hour day I didn’t process what I was looking at correctly. In the nginx config file in the documentation is missing the /php/ folder. Check here: https://docs.librenms.org/Installation/Install-LibreNMS/

Who should I notify? If anyone does an install using these instructions verbatim will fall into the problem as me.

I have the same issue on "upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock”, have anyone alread to resolve it?

*3 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream

Hey @kidd_wu

I just had this issue (albeit using Debian 10).

The three steps I took were:

  1. Edit this file: /etc/php/7.3/fpm/pool.d/librenms.conf
    [line 36] /run/php-fpm-librenms.sock

  2. Edit this file: /etc/nginx/sites-enabled/librenms.vhost
    [line 14] fastcgi_pass unix:/run/php/php-fpm-librenms.sock

  3. systemctl restart nginx

That solved it, no more 502.

I have the same issue. I am however using Apache.

tail -f /var/log/apache2/error.log ;
Mon Oct 25 04:36:45.369330 2021] [proxy:error] [pid 2918:tid 139869300979456] (2)No such file or directory: AH02454: FCGI: **attempt to connect to Unix domain socket /run/php-fpm-librenms.sock () failed

/etc/apache2/sites-available/librenms.conf ;
<FilesMatch “.+.php$”>
SetHandler “proxy:unix:/run/php-fpm-librenms.sock|fcgi://localhost”

/etc/php/7.4/fpm/pool.d/librenms.conf ;
listen = /run/php/php-fpm-librenms.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = librenms
listen.group = librenms
;listen.mode = 0660

You didn’t input the same path in php and apache config

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.