Blog dedicated to Oracle Applications (E-Business Suite) Technology; covers Apps Architecture, Administration and third party bolt-ons to Apps

Monday, October 20, 2008

How to check if a port is in use

This is the most common question asked by DBAs and System Admins.

The easiest way to find out is this:

telnet hostname port number

For example to check if port 22000 is in use, use this command:

telnet 22000

If the port is in use, the screen will go blank.  You can then press Ctrl + ] to get to telnet prompt, from where you can type exit and quit.

If the port is not in use, you'll get a message like  "Connect timed out".  This works for all operating systems supporting TCP/IP that's all unix and all windows versions.


Dan Norris said...

I disagree on two points. First of all, if you're going to offer syntax, it should be complete and concise. If you simply type "telnet", you won't be connecting to anything.

Secondly, I think the easiest way to find out if a port is in use is to use:
netstat -an |grep LISTEN |grep portnum

Anonymous said...

How set max adrress for Oracle security

Vikram Das said...

Hi Dan,

Thanks for the comment. I did not see that only telnet was present in the post. I had written telnet <hostname> <port number>. However < and > are reserved word in html tags, so blogger simply removed those two words. Even in this comment, I have used ampersand lt; and ampersand gt; to represent those two symbol. I have corrected it in my post now.

netstat -an approach has two issues:

1. It will be slower in giving you an answer as it will show you all open ports and then grep for your port

2. You need local access to the server on which you are trying to find the open port

- Vikram