How to find an available port in C# As i discussed in my post Development considerations taken when installing client application on a terminal server , there will be times you will have to find an available port yourself, without relying on WCF to do that for you. This can be achieved by locating all ports currently used in your machine and returning the first port number that is not being used. The machine in question can hold open ports in different communication protocols and states(learn more...