• Home
  • Systems
  • Networking
  • WordPress
  • Web
  • Geekery

Analysis and Review

What process is listening on a port?

April 6, 2009 by Kurt Turner

This article was written so one can figure out what process is listening on a port. I’m going to list how to find out what process is running on a windows port and how to find out what process is running on a unix or linux port.

First lets look at the windows operating system and how to find out what process is using what port.

Open your command prompt and type in netstat -ano  this will list all processes ID and what port it is running or listening on. To open the command prompt click start -> run -> cmd and hit enter. This will open the command prompt. netstat -ano will output as seen below

Type netstat -ano to list processes running and the PID number
Type netstat -ano to list processes running and the PID number

Find the port you’re inquiying about and take note of the PID. Now that you have the PID number (located to the left side of the command prompt) you can open up the task manager to tie that PID to a process / program.

Just hit control + alt + del then click task manager or you can right click the bottom task bar and select task manager from the list.  Once task manager is open you’ll need to tell it to display the PID. To do this open task manger and click -> view -> select columns -> and select PID

Now you can see the PID and the corresponding program / process associated with it.

Finished with windows.. on to UNIX!

How to determine what process is listening on a port in Unix is so much easier.

Let’s say we want to find our what process is tied to port 53.

First, use the following command to find if the port is is use or not
netstat -an | grep 53

#Then, use the following command to find which process is using the port
fuser -n tcp 53
This will return something like ’53/tcp: 5006′.
it shows pid.

After that, we can find the full process information.
ps -ef | grep 9113

If you know shell you can use the below in a shell script to put all these step together

#!/bin/sh
status=`netstat -an |grep $1`
if [ “$status” == “” ]; then
echo “port $1 is free”
exit
fi
ps -ef |grep `fuser -n tcp $1`

Or if you’re running linux download lsof
lsof -i :53

or

lsof -i :1226

Or you and use grep

lsof | grep [process name]

Filed Under: Systems

Comments

  1. Tobias says

    August 9, 2010 at 6:46 am

    Nice! Thanks for this good Linux info! 😀

  2. Kurt says

    August 10, 2010 at 7:16 pm

    you’re welcome Tobias, good luck =)

  3. math says

    November 24, 2012 at 8:44 pm

    this helped me so much ! thank you !

Latest and Greatest

Apache vs Nginx for WordPress

Certbot Lets Encrypt And WordPress MU Multi-Site

How To Find and Replace Multiple File in MS Word

How To Get Stretch Res on Windows 10 AMD Radeon For Game Play

This is the ASUS Chromebox we've been running for 2 years as our "brain" for our home grown digital display kiosk.

DIY Digital Signage Bulletin Board or Kiosk

© Copyright Analysis And Review · All Rights Reserved ·