How to find out which program is using a connection port

netstat

NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-t] [interval]

-a Displays all connections and listening ports.

-b Displays the executable involved in creating each connection or listening port. In some cases, well-known executables host several independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this situation, the executable name is enclosed in [] at the bottom, at the top is the component it called, and so on until TCP/IP is reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.

-e Display Ethernet statistics. Can be combined with the -s option.

-f Displays Fully Qualified Domain Names for external addresses.

-n Displays addresses and port numbers in numeric format.

-o Displays the ID of the proprietary process associated with each connection.

-p proto Show connections for the protocol specified by proto; proto can be: TCP, UDP, TCPv6 or UDPv6. If used with the -s option to display statistics by protocol, proto can be: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6. -r Display the routing table. -s Display statistics by protocol. By default, statistics are shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6; the -p option can be used to specify a subset of the pattern.

-t Displays the current connection's offload state. interval Re-displays selected statistics, taking second intervals between each display. Press CTRL+C to stop re-displaying statistics. If omitted, netstat will print the current configuration information once.

Testing the options I arrived at this: netstat -a -n -b -p tcp, which resulted in this: TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING[mysqld.exe].

Beauty. Mysql was running itself, but I needed to find out why it didn't work. I decided to remove the mysql service and install it again, but now I keep the command here for posterity.

netstat -a -n -b -p tcp

With netstat -a -n -b -p tcp, I have information about the PID and since I'm using things via the command line, a taskkill /PID num_PID /F ends the process, mainly because in this case I specify mysqld.exe did not appear in the Process Manager.

 1,007 Total Visualizações,  1 Visualizações Hoje

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.