You set `nofile 65535` in `/etc/security/limits.conf`, but the systemd service still dies at 1024 open sockets.
BeginnerTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer
Likely causes → limits.conf is applied by PAM to login sessions only. Services started by systemd ignore it and use LimitNOFILE from the unit (or DefaultLimitNOFILE in system.conf).
Diagnose →
systemctl show myapp -p LimitNOFILE -p LimitNOFILESoft
grep 'open files' /proc/$(systemctl show -p MainPID --value myapp)/limits
Fix →
sudo systemctl edit myapp
# [Service]
# LimitNOFILE=65536
sudo systemctl daemon-reload && sudo systemctl restart myapp
Prevent → Put limits in the unit file managed by config management, and verify via /proc/<pid>/limits, not ulimit -n in your shell.
More on Sockets, ports, TIME_WAIT and conntrack
`dmesg` is full of `nf_conntrack: nf_conntrack: table full, dropping packet` and new connections randomly time out.Intermediate`ss -s` on a reverse proxy shows 40,000 sockets in `TIME_WAIT`. Is that a problem?BeginnerAn app server's `CLOSE_WAIT` count grows steadily until the service logs `Too many open files`.IntermediateLogs show `accept4(): Too many open files` and the service stops accepting connections.Beginner`dmesg` shows `TCP: request_sock_TCP: Possible SYN flooding on port 443. Sending cookies.`Intermediate`ss -ltn` shows the listener for port 8080 with `Recv-Q 129` and `Send-Q 128`, and clients hang on connect.Advanced