Sometimes, we couldn't start a docker service, because the configured port was used by another process. To find out which process is using this port.
We can simply create an (zsh) alias
as following:
# ~/.zshrc
alias port='lsof -i -P | grep LISTEN | grep $1'
Then just use this alias port <number>
to find the running process on port 8080
:
➜ ~
❯ port 8080
node 10126 zhouxun 25u IPv4 0x83e36c82e2c8dccb 0t0 TCP *:8080 (LISTEN)
We found the process with PID
10126
and it was a node process.
Then we can kill the process by using(if needed, use sudo
):
➜ ~
❯ kill -9 10126
Top comments (0)