Last Updated: 2024-03-02
We had a node JS server on our machine and the logs suggested it was not receiving any requests from an android app running on an emulator.
The problem was, we were unsure if it was running on the right port. We assumed 3000, but how to check?
$ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 21168 jack 23u IPv6 0x8c31589dd566ee87 0t0 TCP *:hbci (LISTEN)
If nothing was on the port, then the command would return nothing.
Not to be confused with
lsof -p, which looks at PROCESSES.