I'm using CentOS 6.7 (Final) system, and when I try to run nc in listening mode it prints the following:

# nc -l 1234
nc: Protocol not available

The port is not bound. I tried other port numbers too. This bug seem to have been reported already: https://access.redhat.com/solutions/1753753. Unfortunately it is not very detailed.

Package information:

Name        : nc
Arch        : x86_64
Version     : 1.84
Release     : 24.el6

Is there something else I need to try out?

  • Which version of nc are you using?
    – Jenny D
    Oct 18, 2015 at 10:40
  • @JennyD I updated the post, please check out
    – Ilya I
    Oct 18, 2015 at 10:58
  • 1
    Unfortunately the only fix is a downgrade, as described below. I'm also voting to move this question to Unix & Linux since it's not strictly about systems administration. It's a good site with some experts who leave me in awe, so please don't think the close vote is because your question is bad or anything.
    – Jenny D
    Oct 18, 2015 at 11:09

5 Answers 5


I ran into the same issue. You can solve it this way:

# Removes the old package
yum erase nc

# Manually downloads the working package from the Official Repository
wget http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm

# Installs the package
rpm -iUv nc-1.84-22.el6.x86_64.rpm

Please note that the package is for x86_64 (64-bit). If you need i386 (32-bit), the correct one is:

wget http://vault.centos.org/6.6/os/i386/Packages/nc-1.84-22.el6.i686.rpm
  • Using rpm with the -i and -U flags simultaneously looks weird (but works). More standard invocation is -ivh or -Uvh.
    – dmourati
    Jan 4, 2016 at 21:48
  • 1
    work like a charm!
    – Shawn Guo
    Jan 7, 2016 at 6:36
  • This path no longer works
    – BradLaney
    Apr 12, 2016 at 18:52
  • @BradLaney why doesn't?
    – Eddie C.
    Apr 15, 2016 at 10:32
  • @EddieC. The URL was 404ing for me when I made the comment. It appears to be working now. Nevermind.
    – BradLaney
    Apr 15, 2016 at 15:29

This particular version of netcat has a bug. Until there's a fix out for it, the only thing you can do is to downgrade to a previous version - sudo yum remove nc-1.84-24.el6.x86_64; sudo yum install nc-1.84-22.el6.x86_64 should do the trick.

  • 1
    Doesn't yum have an argument which can downgrade to a specific version of a package without first uninstalling?
    – kasperd
    Oct 18, 2015 at 12:09
  • Great, but I was unable to downgrade. Yum says no package available (both the install with specific version and the downgrade command). Also tried searching for that rpm file and hasn't found yet.
    – Ilya I
    Oct 18, 2015 at 13:11

Replying the question:

  1. YES, downgrade is needed so that nc can listen. and as for the other comments:

a) -p is not supposed to be used when in listening mode. from nc manpage:

-l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options.

b) downgrade can be done in one step, yum downgrade command works with the url to the package:

$ rpm -q nc
$ nc -l 12345 #Although the syntax is correct, the command fails
nc: Protocol not available
$ nc -l -p 12345 #attempt to run with incorrect syntax
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]
$ sudo yum downgrade http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm  #shortcut to downgrade
Setting up Downgrade Process
nc-1.84-22.el6.x86_64.rpm                                                              |  57 kB     00:00
Examining /var/tmp/yum-root-Iq4yc7/nc-1.84-22.el6.x86_64.rpm: nc-1.84-22.el6.x86_64
Resolving Dependencies
--> Running transaction check
---> Package nc.x86_64 0:1.84-22.el6 will be a downgrade
---> Package nc.x86_64 0:1.84-24.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

 Package          Arch                 Version                     Repository                            Size
 nc               x86_64               1.84-22.el6                 /nc-1.84-22.el6.x86_64               109 k

Transaction Summary
Downgrade     1 Package(s)

Total size: 109 k
Is this ok [y/N]: y
  nc.x86_64 0:1.84-24.el6

  nc.x86_64 0:1.84-22.el6

$ nc -l -p 12345 #attempt to run with incorrect syntax
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]
$ nc -l 12345 # try to listen again
$#nc successully opens a socket on 12345. had to stop it with ctrl+C
# nc -l -p 1234

You can listen on that port by explicitely using -p flag:

-p source_port
         Specifies the source port nc should use, subject to privilege restrictions and availability.

The problem was along the lines of nc treating 1234 as the destination port (despite being run in listening mode), and trying to listen on port 0 (which produced that weird message). Explicitely passing -p works around it.

  • I tried this on centos 6 and it didn't work using the version nc-1.84-24 The fix was to downgrade to the version nc-1.84-22 as per the accepted answer.
    – Criggie
    Nov 7, 2015 at 23:44
  • that version does not allow using -p with -l.
    – andrej
    Nov 25, 2016 at 11:11

install nmap:

yum install nmap


ncat -l 1234

  • Please read the question and the already supplied answers to learn why your answer isn't sufficient in that particular case.
    – Sven
    Jan 4, 2016 at 19:43
  • Upvoting as this helped me. While @Ronald perhaps did not directly address the OP's concern of getting netcat itself to work, using nmap's ncat tool works the same for at least my use case where my environment did not allow me to downgrade netcat as the popular solution suggests. At the end of the day, I had a tool that allowed me to run a listening tool on a specific port so I could continue on with my project. May 25, 2020 at 18:44

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.