Sometimes I do not know which port is the problem, I just want to know what on this machine is listening at all. lsof can answer that in one line.
Run it with sudo so it can see processes of other users:
sudo lsof -nP -iTCP -sTCP:LISTEN
-iTCP limits the list to TCP sockets and -sTCP:LISTEN keeps only the ones waiting for connections. -n stops lsof from looking up host names and -P shows port numbers instead of service names, so the output stays fast and exact. Each row shows the command, the PID, the user and the address with its port.
Swap -iTCP for -iUDP to see UDP sockets. A service listening on 127.0.0.1 is only reachable from the machine itself, while * means it accepts connections from the network.
A caveat: without sudo you only see your own processes, so a quiet list can be misleading.
One more detail: add -i :443 after the same options to narrow the list to a single port, or add -i4 to leave out IPv6 sockets. Keep in mind that this shows what is open, not what a firewall lets through.
Further reading: lsof(8) man page