How to check which process is using a port in the system

Source: Internet
Author: User

Problem description:

In the process of system management, it is often encountered that the port is occupied when a process is started. For example, port 9090 is often occupied when the WebSphere console is started. Using netstat-an | grep 9090, you can see that the port is being listened on, but you do not know which process occupies the port. Of course, you can change the port but it is troublesome. If you can find out which process occupies the port, kill the process.

Solution:

1. netstat-aan | grep <portnumber>
Find the PCB/ADDR corresponding to the port connection and the protocol type of the connection.

Note: PCB ---- Protocol control block

2. For TCP connection, rmsock <PCB/ADDR> tcpcb
If it is a UDP connection, the rmsock <PCB/ADDR> inpcb uses port 23 used by the telnet service as an example to describe this method:
# Netstat-aan | grep 23
F1000200019ce398 TCP 0 0 *. 23 *. * listen
The PCB/ADDR is f1000200019ce398 and the protocol type is TCP. # Rmsock f1000200019ce398 tcpcb
The socket 0x19ce008 is being held by proccess 185006 (inetd ).
The Command reports that the port is being used by the inetd process and the PID is 185006.

Note: The rmsock Command requires the root permission for execution. If we execute this command as a common user, the following error message is reported:

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.