It is possible with a simple Unix command to find out if we can listen on a port or not? I'm building an application in which the user has the permissions to change the port.

I have to check though if the port is already listening somewhere or not. I want it in Command since i can't use any programming language for other reasons.

Thanky you

1 Answer 1


To check if a port is not already binding using :

$ nc -zw2 <IP> <PORT> && echo "already binding" || echo "Not already binding"

Reminder, users can only use ports > 1024 and < 65536

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.