How to Check Remote Ports are Reachable Using ‘nc’ Command

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

10 Responses

  1. Bernard says:


    Don’t use this for connectivity checks on Centos 7. This only works on Centos 6. It does not work on Centos 7. You need something like this:

    # echo | nc -w1 $server $port >/dev/null 2>&1 ;echo $?

    Its because redhat/centos distro is changed at Centos 7.

  2. Timir Mazumder says:


    I have Red Hat Enterprise Linux Server release 7.3 (Maipo) installed on my PC.

    When I try either of the below commands, I get the error message as shown:

    # ncat -z 5556
    # nc -z 5556

    Error Message:
    nc: invalid option — ‘z’
    Ncat: Try `–help’ or man(1) ncat for more information, usage options and help. QUITTING.

    ‘–help’ or man() did not provide any details on how to simply scan for listening daemons.

    Any suggestions?

  3. Jonathan says:

    Very useful article for security. I’ll test that.Thank you !
    Long life to super penguin ^^

  4. Chris Pesoa says:


    In CentOS 7, there is no package named ‘nc‘.
    Searching for ‘netcat‘:

    $ yum search netcat

    the resulting package is ‘nmap-ncat.x86_64 : Nmap’s Netcat replacement

    If you install this package, the above command will looks like this:

    $ nc --recv-only -z 22

    There is another package ‘netcat-gnu‘. You can read more about this package in:

    Are this observations correct?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.