NguyenTrungTin
6/13/2019 - 7:17 AM

How to know what program is listening on a given port?

How to know what program is listening on a given port?

Open your terminal and type as

```sh
lsof -i :8000
```

For example, with port 8000 (python3 -m http.server):

```sh
$ lsof -i :8000
COMMAND  PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
python3 3269 user    3u  IPv4 1783216      0t0  TCP *:8000 (LISTEN)
And port 22 (SSH):
```

```sh
$ sudo lsof -i :22
COMMAND  PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
sshd     998 root    3u  IPv4 1442116      0t0  TCP *:ssh (LISTEN)
sshd     998 root    4u  IPv6 1442118      0t0  TCP *:ssh (LISTEN)

```sh
fuser 43796/tcp
```

https://askubuntu.com/questions/278448/how-to-know-what-program-is-listening-on-a-given-port
https://askubuntu.com/questions/227161/how-can-we-find-which-process-is-using-a-particular-port
```