Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
 
Search the VMware Knowledge Base (KB)   View by Article ID
 

Determining if a port is in use

Purpose

For troubleshooting purposes, it may be necessary to check if a port is already in use by a different application on your servers.

This article provides steps to use the Netstat utility to check the ports in use and view the application that is utilizing the port.

Resolution

Checking port usage from Windows

To check the listening ports and applications with Netstat:

  1. Open a command prompt. For more information, see Opening a command or shell prompt (1003892).
  2. Run this command:

    netstat -ban

    You see an output similar to:

    C:\netstat -ban

    Proto    Local Address    Foreign Address    State        PID
    TCP      0.0.0.0:port     0.0.0.0:0          LISTENING    process ID
    [process.exe]
    TCP      0.0.0.0:port     0.0.0.0:0          LISTENING    process ID
    [process.exe]
    ...

    where:

    • process is the name of the application
    • port is the port that is being used
    • process ID is the process ID of the process

The output shows the processes that are listening, as well as the name of the process and process ID. When reviewing the information, only look at the ports that are listening to ensure that you find the correct application that is listening on that port. If you do not see any process listening for a port, that port is free to be utilized.

When you determine what is listening on the port, you must decide what action needs to be taken to resolve the conflict. This involves stopping a service or uninstalling the application that is utilizing the port.

Checking port usage from Linux / Mac OS / ESX

Note: Mac OS and certain distributions of Linux do not support listing the process name with Netstat. If you are using Mac OS or are seeing errors on your distribution of Linux, follow the lsof instructions below.

To check the listening ports and applications with Netstat:

  1. Open a shell prompt. For more information, see Opening a command or shell prompt (1003892).
  2. In the shell prompt window, run this command:

    netstat -pan

    You see an output similar to:

    [root@server]# netstat -pan

    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address   Foreign Address State    PID/Program name
    tcp        0      0 0.0.0.0:port    0.0.0.0:*       LISTEN   process ID/process
    tcp        0      0 0.0.0.0:port    0.0.0.0:*       LISTEN   process ID/process

    ...

    where:

    • process is the name of the application
    • port is the port that is being used
    • process ID is the process ID of the process

To check the listening ports and applications with lsof:

  1. Open a shell prompt. For more information, see Opening a command or shell prompt (1003892).
  2. In the shell prompt window, run this command:

    lsof -i -P -n

    You see an output similar to:

    [root@server]# lsof -i -P -n
    COMMAND   PID          USER   FD   TYPE   DEVICE SIZE   NODE  NAME
    process   process ID   root   3u   IPv4   3011          TCP   *:port (LISTEN)
    process   process ID   root   3u   IPv4   3011          TCP   *:port (LISTEN)
    ...


    where:

    • process is the name of the application
    • port is the port that is being used
    • process ID is the process ID of the process

The output from either of these two commands shows the processes that are listening, the name of the process, and the process ID. When reviewing the information it is important to only look at the ports that are listening to ensure that you find the correct application that is listening on that port. If you do not see any process listening for a port, than this means that it is free to be utilized.

When you determine what is listening on the port, you must decide what action needs to be taken to resolve the conflict. This involves stopping a service or uninstalling the application that is utilizing the port.

Tags

port-availability  port-in-use  check-ports

See Also

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback


Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (4000 or fewer characters)
Actions