title: Java sockets error: java.net.ConnectException: Connection refused: connect
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9555363/java-sockets-java-net-connectexception-connection-refused-connect">Java sockets - java.net.ConnectException: Connection refused: connect</a>  </p>
  </blockquote>
  
  
  
  <p>I've created a simple chat program which communicates using sockets. Everything works fine when I'm running it on localhost. However, the problems occur when I try to link the client and server programs using my IP.</p>
  
  <p><a href="http://www.canyouseeme.org/" rel="nofollow noreferrer">http://www.canyouseeme.org/</a> can connect to my server on port 9999 so <strong>I know that the server is fine and the port is open</strong>. However, my client can't connect.</p>
  
  <p>The error log...</p>
  
  <pre><code>java.net.ConnectException: Connection refused: connect
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.PlainSocketImpl.doConnect(Unknown Source)
  at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
  at java.net.PlainSocketImpl.connect(Unknown Source)
  at java.net.SocksSocketImpl.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at java.net.Socket.&lt;init&gt;(Unknown Source)
  at java.net.Socket.&lt;init&gt;(Unknown Source)
  at Client.connect(Client.java:129)
  at Client.main(Client.java:47)
  </code></pre>
  
  <p>Does anybody have any idea what might be causing this? Thanks in advance.</p>
  
  <p>Links to the full source code: </p>
  
  <p><a href="http://pastebin.com/2XftHtn9" rel="nofollow noreferrer">http://pastebin.com/2XftHtn9</a></p>