This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the networking category.
Last Updated: 2024-11-21
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?
Answer:
$ lsof -i :3000
Bingo:
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.