We often come across the following error while starting our servers:
address already in use
And it’s not always super clear which process is holding the port.
There is a powerful command, lsof
, in the Linux and Mac environments that comes handy.
For example, we can find which process is holding port 8080 using the following command:
lsof -i tcp:8080
The above command gives you the PID and the name of the process.
COMMAND | PID | USER | FD | TYPE | DEVICE | SIZE/OFF | NODE | NAME |
---|---|---|---|---|---|---|---|---|
xxxx | 123 | user1 | … | … | … | … | … | apache |
Happy coding!!!
RELATED TAGS
CONTRIBUTOR
View all Courses