Kill the process that occupies the specified port

Source: Internet
Author: User

Sometimes when Tomcat is started, it fails to start, saying that the port is already occupied, so which program takes up the port?
How can I tell which process (program) is taking up the specified port?
Below I will be divided into two platforms (Windows,linux) for detailed description

    1. Windows system

Use the following command to find the PID (process ID) that occupies the specified port

<指定的端口号>

For example, find a process that occupies port 8080

Indicates that a process with a PID of 1532 consumes 8080 ports

Then we open the Task Manager, find the process,

So how do we kill the process?

taskkill  1532  /f


Note: PID is followed by

    1. Linux

Use the following command to find the PID (process ID) that occupies the specified port

-aonp|":80[ ]\+"|-F" "   {‘print $0‘}

This is the process of querying 80 ports

Indicates that a process with a PID of 11116 consumes 80 ports
The following optimizations are followed:

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


Well, let's check it out.

Sure enough, Tomcat takes up 80 ports.
What if only PID is displayed?

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

So how do you kill the process in Linux?

kill -911116

My technical blog on the Iteye:
http://hw1287789687.iteye.com/

Kill the process that occupies the specified port

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.