title: WebSocket connection to failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
body: <p>I am using Ratchet to create websockets for a chat and I get an error that says: </p>
  
  <p><code>main.js</code>:2 WebSocket connection to <code>ws://localhost:8080/</code></p>
  
  <p><code>failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED</code></p>
  
  <p>The code from which I get the error is the following: </p>
  
  <pre><code>$(document).ready(function () {
      var conn = new WebSocket('ws://localhost:8080');
      var chatForm = $(".chatForm"),
          messageInputField = chatForm.find("#message"),
          messagesList = $(".messages-list"),
          usernameForm = $(".username-setter"),
          usernameInput = usernameForm.find(".username-input");
  </code></pre>
  
  <p>I also changed the IP in the <code>/etc/host</code> to <code>0.0.0.0</code> just to be sure.
  Anything you can suggest to change and fix this error?</p>