Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
This blog shows how to find TCP ports used or reserved by applications on Windows. It is not related to specific SAP applications.

Problem:
An application cannot start, because the port it wants to use, is in use by another application (or components of the operating system).
How can we found out which application uses this port?

Example:

SAP Message Server executable cannot start, because the ports it wants to open is in use by another application.
The ports which should be used in this example are: 3600 and 3900.

 

Use netstat -anob to list all established and listening ports


The command "netstat -anob" shows all in-use ports and the binary (application) which use them.

Example:


In this example we see the process msg_server.exe which is listening on ports 3600 and 3900.
Another msg_server.exe which tries to bind these ports, must therefore fail.

 

Use netstat -anoq to list all bound ports (= reserved ports)


The command "netstat -anoq" additionally shows a list of all ports in "bound" state. Unfortunately, the option "b" for binary cannot be used in conjunction with the "q" parameter.

Example


To get a nicer list of bound ports, use this PowerShell command line:
Get-NetTCPConnection -State Bound | ForEach-Object {$p = (Get-Process -Id $_.OwningProcess);New-Object -TypeName psobject -Property @{ "LocalPort" = $_.LocalPort; "PID" = $p.Id; "ProcessName" = $p.Name; }} | Format-Table -AutoSize -Property PID, ProcessName, LocalPort

 

Example:


In this list we see SAP applications, but also Windows components like Cluster service (clussvc.exe), Cluster Resource Monitor (rhs.exe), Microsoft Management Console (MMC) and other applications.

A bound port can also be in established state (all SAP applications in above example have a related "established" entry.

Port 61493 is in use by Windows services host (svchost), but "netstat -ano" shows no related established port. In this case, the port is "reserved" by the OS for this application.
Summary:
Look for applications / processes which appear in the bound-list, but not in the established-list.

If you want to search for applications that use/reserve a specific port, netstat -ano is not sufficient. You need to look also for ports in "bound" state.

 

Links:

https://superuser.com/questions/557665/determining-what-process-has-bound-a-port-without-listening-o...

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat