Kill the process that occupies the specified port and the process that occupies the specified port

Source: Internet
Author: User

Kill the process that occupies the specified port and the process that occupies the specified port

When tomcat is started, it fails to be started. If the port is occupied, which program occupies the port?
How can I determine which process (Program) occupies the specified port?
I will describe it on two platforms (windows and linux ).

Run the following command to find the pid (process id) that occupies the specified port)

Netstat-ano | findstr <specified port number>

For example, you can find the process that occupies port 8080.

It indicates that processes with a pid of 1532 occupy port 8080.

Then, open the task manager and find the process,

So how to kill the process?

taskkill  /pid 1532  /f


Note: pid is followed by pid.

Run the following command to find the pid (process id) that occupies the specified port)

netstat -aonp |grep ":80[ ]\+"|awk -F" "   {'print $0'}

This is the process used to query port 80

The process with pid 11116 occupies port 80.
After optimization:

netstat -aonp |grep "^[a-z]\+[ ]\+0[ ]\+0[ ]\+[0-9\.]\+:80[ ]\+"|awk -F" "   {'print $0'}


Let's verify it.

Tomcat occupies port 80.
What if only pid is displayed?

netstat -anp |grep "^[a-z]\+[ ]\+0[ ]\+0[ ]\+[0-9\.]\+:80[ ]\+"|awk -F" "   {'print $7'}|cut -d"/" -f1

In linux, how does one kill a process?

kill -9 11116

My technical blog on ITEye:
Http://hw1287789687.iteye.com/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.