Skip to content

Find out TCP/UDP port and service on MacOS



When troubleshooting network issues on your MacOS device, it is important to know which TCP/UDP ports are being used by which services. This information can help you diagnose and resolve connection issues, as well as ensure that your network is secure. In this blog post, we will guide you on how to find out TCP/UDP port and service on your MacOS device.

Using Terminal to find TCP/UDP port and service

  1. Open the Terminal app on your MacOS device.
  2. Type in the following command: sudo lsof -iTCP -sTCP:LISTEN -n -P
  3. Press Enter. You will be prompted to enter your administrator password.
  4. This will display a list of all TCP ports that are currently open and the services that are using them. You can also specify UDP ports by typing iUDP instead of iTCP.
  5. If you want to see all established connections, type in the following command: sudo lsof -iTCP -n -P | grep ESTABLISHED


echo "### TCP LISTEN ###"
lsof -nP -iTCP -sTCP:LISTEN
echo "### UDP LISTEN ###"
lsof -nP -iUDP -sTCP:LISTEN
Small world. Big idea!
  • Welcome to visit the knowledge base of SRE and DevOps!
  • License under CC BY-NC 4.0
  • No personal information is collected
  • Made with Material for MkDocs and generative AI tools
  • Copyright issue feedback, replace # with @
  • Get latest SRE news and discuss on Discord Channel