title: java.net.BindException: Permission denied as root
body: <p>I'm following Oracle's ServerSide Socket tutorial at <a href="http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html</a>. I use the source as they provide it:</p>
  
  <ul>
  <li><a href="http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockServer.java" rel="nofollow">http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockServer.java</a></li>
  <li><a href="http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockProtocol.java" rel="nofollow">http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KnockKnockProtocol.java</a></li>
  </ul>
  
  <p>However, when I try to run the KnockKnockServer, I get an IOException and then the server prints</p>
  
  <pre><code>Could not listen on port: 4444.
  </code></pre>
  
  <p>I added a <code>e.printStackTrace()</code> in the IOException catch block, and get:</p>
  
  <pre><code>[beni@mackerel:~]$ \sudo java KnockKnockServer
  Creating socket
  Could not listen on port: 4444.
  java.net.BindException: Permission denied
      at java.net.PlainSocketImpl.socketBind(Native Method)
      at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
      at java.net.ServerSocket.bind(ServerSocket.java:328)
      at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:194)
      at java.net.ServerSocket.&lt;init&gt;(ServerSocket.java:106)
      at KnockKnockServer.main(KnockKnockServer.java:41)
  </code></pre>
  
  <p>Notice, I'm running it as root and try to open port 4444. Why do I still get a Permission denied error?</p>