See what process is using a specific port

For Mac (if no netstat):

PORT=8080
sudo lsof -n -i4TCP:$PORT | grep LISTEN
sudo lsof -n -iTCP:$PORT | grep LISTEN
sudo lsof -n -i:$PORT | grep LISTEN

For Linux (if no lsof):

netstat -tulpn | grep $PORT

View active ports on Linux with netstat

to see which ports are active, use netstat:

sudo netstat -antuwp | egrep "(^[^t])|(^tcp.*LISTEN)"