Interview Prep/Networking/Sockets, ports, TIME_WAIT and conntrack

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.

All Networking questions Roadmap: Networking for DevOps

More on Sockets, ports, TIME_WAIT and conntrack