How to find a free TCP port

AJF picture AJF · Mar 11, 2015 · Viewed 17.5k times · Source

How do I find a completely free TCP port on a server? I have tried the command line;

netstat -an

but I am told the ones with a status of LISTENING are already being used.

I also tried a tool called TCPView but again it only showed which TCP ports were being used. I know how to telnet to a port to check its open but I need to find one that is free.

Answer

NeverGiveUp161 picture NeverGiveUp161 · Mar 11, 2015

netstat -lntu

This will solve your purpose.