View the process that occupies the port and kill the process

Source: Internet
Author: User
Tags port number

1. View process information for occupied ports

Netstat-aon | Findstr "Port number"

The port number here is filled in according to the actual situation, such as NETSTAT-AON|FINDSTR "8888", output:

TCP 127.0.0.1:8888 0.0.0.0:0 LISTENING 5824

The PID of a process that occupies 8888 ports is 5824

2. View the process name according to the PID

tasklist | Findstr "PID"

Like Tasklist | Findstr "5824", Output:

Javaw.exe                     5824 Console                    1     43,748 K

3. Kill the Process

C:\users\administrator>taskkill/pid 5824/f
succeeded: The process of PID 5824 has been terminated.

Some times appear:

Error: Unable to terminate the process with PID 5824.
cause: This process can only be forcibly terminated (with/F option).

You will need to use the/F parameter at this time.

Summarize:

1. Process can be killed according to the process name

Taskkill/im "process name", such as: Taskkill/im notepad.exe

2. Kill multiple processes at the same time

Taskkill/im Notepad.exe/im Iexplorer.exe

3. Port status listening status

The FTP service is first in the listening (LISTENING) state after it is started. established status

Established means to establish a connection. Indicates that two machines are communicating. close_wait

When the other side actively shuts down the connection or the network exception causes the connection to be interrupted, our state becomes close_wait at this time we want to call Close () to make the connection close properly time_wait

We actively call Close () to disconnect and receive confirmation from the other party that the status becomes time_wait. The TCP protocol states that the TIME_WAIT state will continue to be 2MSL (that is, twice times the maximum segment lifetime) to ensure that the old connection state does not affect the new connection. The resources in the TIME_WAIT state are not freed by the kernel, so as a server, try not to disconnect as aggressively as possible to reduce the resource waste caused by the time_wait state.

There is a way to avoid wasting time_wait resources, which is to close the socket linger option. However, this approach is deprecated by the TCP protocol, which may cause errors in some cases. syn_sent Status

Syn_sent status indicates a request to connect, when you want to access the service of other computers to the first to send a synchronization signal to the port, the state is syn_sent, if the connection succeeds to become established, the Syn_sent state is very short. But if you find that syn_sent is very much and is being sent to different machines, your machine may be infected with a shock wave or a concussion. In order to infect other computers, this kind of virus will scan other computers, in the process of scanning for each computer to be scanned to make a synchronous request, which is also the cause of many syn_sent.





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.