Every programs need to occupy an available port or socket for being connected to a network. The network may be an Intranet or it can be the internet. Suppose you are connecting two or more computers through LAN, or you are making a cluster of computers for some high performance work, you need to communicate between the programs running in those computers. For that you need to know the IP address and the port/socket number to find any specific application. If you only tell the name of the application, then that won’t work. Because behind the scene, each application is uniquely identified by its unique id and these Ids are associated with the ports or sockets.
TCP/IP ports
Each application used its current socket for its entire lifetime. i.e., it can get a new port address when you run it for the next time. but it can’t change once it got a port number till the termination.
Some applications have dedicated fixed ports, like HTTP (Hyper Text Transfer protocol) uses port 80, FTP (File Transfer Protocol) uses port 21 or 20, Telnet has dedicated port 23,
SMTP (Simple Mail Transfer Protocol) uses port 25 etc. Port number 1 to 1024 are reserved for these system tasks purpose. The other port addresses are used for other applications.
To check which application is using what port, you can follow the procedure shown below.
Use the command line and Task Manager to check the ports
1. Open the Task Manager, by right clicking on the taskbar and then selecting Open Task Manager
or by pressing the buttons Ctrl + Shift + Esc. Now go to the File Tab -> Run new task.
2. Then you will see Run window. Check the box at the bottom showing Create this task with administrative privileges to run the task as an administrator.
Write cmd into the input area and press Enter. Or you can simply use the Quick Access Menu by pressing Windows + X.
Now, the administrative command prompt will appear. You will see Administrator is written in the bar. It indicates that you have the privilege to perform administrative tasks.
3. Now, simply type this command
netstat -aon | more
in the command prompt
and press Enter.
4. Now you will see a table with the Local Address column, which will show you the port address and PID column, which shows the Process Identifier (PID) number of the process which is listening (using) to that particular port. In the figure given below, from the table, you can see that Local Address 0.0.0.0:554 or port 554 is being used (Listening) by the process having the PID 6492.
The PID is the unique identifier for each and every process and no other process can get this ID when this process is running. This PID can be given to another process after the termination of this one.
5. Now, open theTask Manager and navigate to the Services tab, there you will get the PIDs of all programs running correctly. Here I find that can see that WMPNetworkSvc has the PID 6492 and currently, it is running. So it is clear that WMPNetworkSvc is using port 554 now. You can terminate this program to release the port from this application.
Thus you can easily checkout, which port is listening to which program and what are the available ports.
I am trying to run a program that uses port 9000 but that port is in use. Using your tutorial I am able to see the ports PID. But when I go to find that PID in the task manager under services it is not there. Any ideas?
Hi Kyle,
It may possible that currently the service is in Stopped or Suspended mode and not using the port but it has secured the port for future use. If you force some other program to use the port the previous service will release the port (unless it is a well know port) and will use different port during future communication.
Cheers
Nick
I have used your totorial and i found it very helpfull. i am currently trying to run minecraft, but the port does not show up. i get a socket error that says (SocketException: unrecognized windows error: 10107:create) i’m not big into all this sort of stuff. Do i need to create a port? is that even a thing?
hii,i want to configure my ftp server and i want to know my ftp port…..pls help