Ports page gateway timeout

We recently upgraded to a new server by installing LibreNMS and importing the database and copying over the rrd files. Everything works great except when clicking on the ports page for any device will bring up the 504 Gateway Time-out. No other page seems to have that issue.

nginx error log
2023/06/21 08:45:28 [error] 1322#1322: *142139 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server: apollo.netviscom.com, request: “GET /device/1239/ports HTTP/1.1”, upstream: “fastcgi://unix:/run/php-fpm-librenms.sock”, host: “apollo.netviscom.com”, referrer: “LibreNMS

php8.2-fpm has the memory limit set as 4G


Component Version
LibreNMS 23.5.0-21-gf4c739c17 (2023-06-18T22:22:41-05:00)
DB Schema 2023_04_27_164904_update_slas_opstatus_tinyint (252)
PHP 8.2.7
Python 3.9.2
Database MariaDB 10.5.19-MariaDB-0+deb11u2
RRDTool 1.7.2
SNMP 5.9

[OK] Composer Version: 2.5.8
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] Distributed Polling setting is enabled globally
[OK] Connected to rrdcached
[OK] Active pollers found
[OK] Dispatcher Service is enabled
[OK] Locks are functional
[OK] Python wrapper cron entry is not present
[OK] Redis is functional
[OK] rrdtool version ok
[OK] Connected to rrdcached

I increased the timeouts for nginx and php-fpm to 5 min. The ports load for some devices but still times out on other devices. I could not find a correlation to devices and the number of ports. Some devices with a couple hundred ports would load immediately while other devices with 5 ports might time out.

After much troubleshooting and frustration (lol), I ended up testing the changes from here https://www.coryfiala.com/fix-slow-loading-pages-graphs-librenms-ports/. Essentially I commented out ifInNUcastPkts and ifOutNUcastPkts from the shared_oids in ports.inc.php. Ports load time went from timing out after 5 min to around 30 seconds. This worked great except that it broke updates. Now to figure out why those oids break it.