Zakariyya / blog

https://zakariyya.github.io/blog/
6 stars 1 forks source link

How to kill a currently using port on localhost in windows?[TOP] #69

Open Zakariyya opened 4 years ago

Zakariyya commented 4 years ago

date: 2030.08.16 16:37:39

you can use port 5000, no 4000 in hexo, like this

hexo s -p 5000 

Step 1

Run command-line as an Administrator. Then run the below mention command. type your port number in yourPortNumber

netstat -ano | findstr :yourPortNumber

C:\Users\yaokunyi>netstat -ano | findstr :35729
TCP    0.0.0.0:35729          0.0.0.0:0              LISTENING       5396
TCP    [::]:35729             [::]:0                 LISTENING       5396 

See the PID ? In here the port is 5396 (process identifier)

Step 2

Then you execute this command after identify the PID. (/F forcefully terminates the process)

taskkill /PID typeyourPIDhere /F

C:\Users\yaokunyi>taskkill /PID 5396 /F
SUCCESS: The process with PID 5396 has been terminated.

P.S. Run the first command again to check if process is still available or not. You'll get empty line if process is successfully ended.


By stackoverflow

近期频繁使用 gitbook ,发现gitbook有时会出现端口被占用的问题无法启动服务,也是郁闷到底是谁占用的。