title: Nodejs can't establish a connection to the server at ws:// apache proxy
body: <p>I am trying to configure my nodejs application to run on localhost with a domain name.</p>
  
  <p>So my website on local is <code>http://app.local</code> which points to <code>http://localhost/app</code></p>
  
  <p>Now I have an app on nodejs which runs on 6060 port <code>http://localhost:6060</code></p>
  
  <p>I am trying to configure <code>localhost:6060</code> to work on <code>http://app.local/nodejs</code></p>
  
  <p>Here's my apache config file.</p>
  
  <pre><code> &lt;VirtualHost app.local&gt;
      ServerAdmin webmaster@app.local
      ServerName app.local
      ServerAlias app.local
  
      DocumentRoot /var/www/app
  
      ProxyPass /service http://localhost:3000
      ProxyPassReverse /service/ http://localhost:3000/
  
      ProxyPass /nodejs http://localhost:6060
      ProxyPassReverse /nodejs/ http://localhost:6060/
  
      ProxyPass /nodejs ws://localhost:6060
      ProxyPassReverse /nodejs/ ws://localhost:6060/
  
      &lt;Directory &gt;
          Options FollowSymLinks
          AllowOverride None
      &lt;/Directory&gt;
  
      &lt;Directory /var/www/app&gt;
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Order allow,deny
          allow from all
      &lt;/Directory&gt;
  
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
      &lt;Directory "/usr/lib/cgi-bin"&gt;
          AllowOverride None
          Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
  
      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn
  
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      Alias /doc/ "/usr/share/doc/"
      &lt;Directory "/usr/share/doc/"&gt;
          Options Indexes MultiViews FollowSymLinks
          AllowOverride None
          Order deny,allow
          Deny from all
          Allow from 127.0.0.0/255.0.0.0 ::1/128
      &lt;/Directory&gt;
  
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>My javascript code listen emits:</p>
  
  <pre><code>var socket = io.connect('http://app.local/', {path:'/nodejs/socket.io/', port: 6060});
  socket.on('connect', function(){
      console.log("Connected");
  });
  </code></pre>
  
  <p>When I try to run the app through this URL <code>http://app.local/nodejs</code>, it throws following error:</p>
  
  <p><code>Firefox can't establish a connection to the server at ws://app.local/nodejs/socket.io/?EIO=3&amp;transport=websocket&amp;sid=NQ2LSn--THwZkrStAAAH.</code></p>
  
  <p>I followed this <a href="https://stackoverflow.com/questions/27526281/websockets-and-apache-proxy-how-to-configure-mod-proxy-wstunnel">question</a> but still not working.</p>
  
  <p>I am using Apache/2.4.7 (Ubuntu)</p>