Checkout this thread Ubuntu 20.04 install "502 Bad Gateway"
Specifically this:
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)