Use cmd command netstat to view system port usage under Windows

Source: Internet
Author: User

Start-run--cmd Enter the command prompt to enter Netstat-ano to see all the connected PID after the PID in the task Manager to find the corresponding program if the Task Manager does not have the pid , you can select the Task Manager "View"-"Select column"

Often, we start the application when the system needs to find the port is occupied by other programs, how to know who owns the port we need, a lot of people are more headache, the following is a very simple method, we hope to be useful

If we need to determine who's taking up our 9050 port,

1. Windows platform
Execute under Windows command-line window:
1. View all port usage

c:\>Netstat-ano

Protocol local address external address state PID

TCP 127.0.0.1:1434 0.0.0.0:0 LISTENING 3236
TCP 127.0.0.1:5679 0.0.0.0:0 LISTENING 4168
TCP 127.0.0.1:7438 0.0.0.0:0 LISTENING 4168
TCP 127.0.0.1:8015 0.0.0.0:0 LISTENING 1456
TCP 192.168.3.230:139 0.0.0.0:0 LISTENING 4
TCP 192.168.3.230:1957 220.181.31.225:443 established 3068
TCP 192.168.3.230:2020 183.62.96.189:1522 established 1456
TCP 192.168.3.230:2927 117.79.91.18:80 established 4732
TCP 192.168.3.230:2929 117.79.91.18:80 established 4732
TCP 192.168.3.230:2930 117.79.91.18:80 established 4732
TCP 192.168.3.230:2931 117.79.91.18:80 established 4732

2. View the usage of the specified port
c:\>netstat-aon|findstr "9050"

Protocol local address external address state PID

TCP 127.0.0.1:9050 0.0.0.0:0 LISTENING 2016

P: See, Port is occupied by process number 2016 process, continue to execute the following command: (You can also go to the task Manager to see the PID corresponding process)

3. View the PID corresponding process
c:\>tasklist|findstr "

Image name PID session name Session # Memory usage
========================= ========================
Tor.exe Console 0 16,064 K

P: Well, it's clear that Tor is taking up your port.

4. End the process

c:\>taskkill/f/t/im tor.exe

Other do not understand the use of Help bar ~

netstat The function of a command is to display network connections, routing tables, and network interface information to let users know which network connections are currently in operation.

The general format of the command is:

netstat [options]

The meanings of the options in the command are as follows:

-a displays all sockets, including those being monitored.

-C Displays it again every 1 seconds until the user interrupts it.

-I displays information for all network interfaces, in the same format as "Ifconfig-e".

-N Displays the network connection situation by replacing the name with the network IP address.

-R Displays the core routing table in the same format as "Route-e".

-T shows the connection condition of the TCP protocol.

-U Displays the connection condition of the UDP protocol.

-V Displays the work in progress.

-a displays the address of any associated protocol control block. Mainly used for debugging

-a displays the status of all sockets. In general, the socket associated with the server process is not displayed

-I displays the status of the auto-configuration interface. The interface state that is configured after the initial boot of the system is not in the output column

Usage of-M print network memory

-N Print the actual address, not the interpretation of the address or display the host, network name and other symbols

-R Print Route selection table

-F address-family Prints statistics and control block information for the address cluster given the name. So far, the only supported address cluster is inet

-I interface only print the interface state given the name

-P Protocol-name Print only the statistics and protocol control block information for the protocol that gives the name

-S print statistics for each protocol

-T replaces queue Length information with time information in the output display.

Column headings for the netstat command

The name of the name interface

Maximum transmission unit of the Mtu interface

The network where the Net/dest interface resides

IP address of the address interface

IPKTS Number of packets received

Ierrs number of packets that were corrupted when received

OPKTS Number of packets sent

Oeers number of packets that were corrupted when sent

Collisions number of network conflicts logged by this interface

Some common options for netstat:

netstat-s--this option to display their statistics separately according to each protocol. If your application (such as a Web browser) is running slowly, or you cannot display data such as a Web page, you can use this option to view the information displayed. You need to take a closer look at the rows of the statistics, find the keywords that went wrong, and then identify the problem.

netstat-e--This option is used to display statistical data about Ethernet. The items it lists include the total number of bytes sent, the number of errors, the number of deletes, the number of datagrams, and the number of broadcasts. These statistics have both the number of datagrams sent and the number of datagrams received. This option can be used to count some basic network traffic).

netstat-r--This option to display information about the routing table, similar to what you see later when you use the Routeprint command. In addition to showing valid routes, the currently active connection is displayed.

netstat-a--This option displays a list of all valid connection information, including established connections (established), and also those connected to the Listener connection request (LISTENING).

bnetstat-n--shows all valid connections that have been established.

The state meaning of «awkphp classic»netstat-an

Meaning of state in Netstat-an

LISTEN: Listening for connection requests from a remote TCP port

Syn-sent: Wait for a matching connection request after sending the connection request

Syn-received: Wait for confirmation of connection request after receiving and sending a connection request

Established: Represents an open connection

Fin-wait-1: Waiting for a remote TCP connection interrupt request, or confirmation of a previous connection interrupt request

Fin-wait-2: Waiting for connection interrupt request from remote TCP

Close-wait: Waiting for a connection interrupt request from a local user

CLOSING: Waiting for remote TCP to confirm connection interruption

Last-ack: Waiting for acknowledgement of the original connection interrupt request to the remote TCP

Time-wait: Wait enough time to ensure that the remote TCP receives a connection interrupt request acknowledgement

CLOSED: No connection status

Actually can man netstat, look at the stat part of the explanation

State

The state of Thesocket. Since There is no states in raw mode and usually no states used INUDP

Blank. Normally thiscan be one of several values:

Established

The socket has anestablished connection.

Syn_sent

The socket isactively attempting to establish a connection.

Syn_recv

A connection Requesthas been received from the network.

Fin_wait1

The socket is Closed,and the connection are shutting down.

Fin_wait2

Connection is closed,and the socket was waiting for a shutdown from the remote end.

Time_wait

The socket is waitingafter close to handle packets still in the network.

CLOSED the socket isnot being used.

Close_wait

The remote end Hasshut down and waiting for the socket to close.

Last_ack

The remote end Hasshut down, and the socket is closed. Waiting for acknowledgement.

LISTEN the socket islistening for incoming connections. Such sockets is not included in the outputunless you specify

The–listening (-L) or–all (-a) option.

CLOSING

Both Sockets is shutdown but we still don ' t has all of our data sent.

UNKNOWN

The state of Thesocket is unknown

Use cmd command netstat to view system port usage under Windows

Related Article

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.