How to Check Open Ports on Windows, Mac and Linux (and Close the Ones You Don't Need)
Check open ports with netstat -ano or Get-NetTCPConnection on Windows, sudo lsof -iTCP -sTCP:LISTEN -n -P on a Mac, and sudo ss -tulpn on Linux. Then match each port to its program and close or firewall anything you don't need.