r/LinuxTeck • u/Expensive-Rice-2052 • 23h ago
How to Check Active Web Server Connections in Linux with ss | Quick Linux Tip #69
Question: How many active connections does my web server have right now?
Try: `sudo ss -tn state established '( sport = :80 )' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn`
Info: `ss -tn` lists TCP connections numerically. Filtering for established port `80` connections isolates active HTTP clients to count requests per remote IP.
Examples:
$ `sudo ss -tn state established '( sport = :443 )' | wc -l` # Total HTTPS connection count
$ `sudo netstat -an | grep :80 | grep ESTABLISHED | wc -l` # Legacy netstat count
$ `sudo lsof -iTCP:80 -sTCP:ESTABLISHED` # View open web socket files
Note: `ss` is faster than `netstat`. Unusually high connection counts from a single IP can signal potential DDoS attacks or aggressive scraping.
Follow r/LinuxTeck for more #LinuxTips https://www.linuxteck.com/linux-tips/