Cách tìm process đang chạy trên port trong Windows, Linux và MAC

Trong quá trình làm việc sẽ có lúc mình gặp lỗi ví dụ như không start được server do port đang được sử dụng bởi một process nào khác, như ví dụ như hình bên dưới khi mình start Tomcat trong Eclipse:

Để giải quyết lỗi này, mình cần kill process đang chạy trên port đó. Sau đây là một vài command để tìm ra process đang chạy trên port và kill nó trên Windows, Linux, MAC.

Windows:

Vào command line (Windows + R -> Gõ cmd -> Enter)
netstat -ano | findstr :<<port>>
taskkill /PID <<process_id>> /F

 

Linux:

Vào command line (Application -> Terminal)
netstat -nlp|grep <<port>>
kill -9 <<process_id>>

 

MAC:
lsof -n -i4TCP:8080

kill -9 <<process_id>>

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *