title: connecting ionic4/socket.io to expressjs net::ERR_CONNECTION_REFUSED
body: <p>I get <code>net::ERR_CONNECTION_REFUSED</code> all the time, even when the server is not running.</p>
  
  <p>When running the application through my browser it works fine, but, then through the device and ran natively I get the error above.</p>
  
  <p>I feel like I have tried everything to resolve this issue. I have read so so so many stack overflow questions with the same issue. and none of them have helped.</p>
  
  <p>app.module:</p>
  
  <pre><code>import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
  const config: SocketIoConfig = { url: 'http:localhost:8080', options: {}};
  </code></pre>
  
  <p>note: above I have also tried:</p>
  
  <blockquote>
    <p>'<a href="https://localhost:8080" rel="nofollow noreferrer">https://localhost:8080</a>'</p>
    
    <p>'<a href="https://localhost:8080/" rel="nofollow noreferrer">https://localhost:8080/</a>'</p>
    
    <p>'<a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a>'</p>
    
    <p>'127.0.0.1:8080'</p>
    
    <p>'127.0.0.1:8080/'</p>
    
    <p>'<a href="http://127.0.0.1:8080" rel="nofollow noreferrer">http://127.0.0.1:8080</a>'</p>
    
    <p>'<a href="http://127.0.0.1:8080/" rel="nofollow noreferrer">http://127.0.0.1:8080/</a>'</p>
    
    <p>'<a href="https://127.0.0.1:8080" rel="nofollow noreferrer">https://127.0.0.1:8080</a>'</p>
    
    <p>'<a href="https://127.0.0.1:8080/" rel="nofollow noreferrer">https://127.0.0.1:8080/</a>'</p>
  </blockquote>
  
  <p>socketio server:</p>
  
  <pre><code>const app = require('express')();
  const PORT = process.env.CHAT_PORT || 3000;
  const ENV = process.env.NODE_ENV || 'development';
  const server = require('http').createServer(app , {origins: 'http://127.0.0.1:8100'}); 
  const io = module.exports.io = require('socket.io')(server);
  const SocketManager = require('./lib/SocketManager');
  </code></pre>
  
  <p>note: I have tried all the same variations as above in the <code>origins:</code> except changing the port since my Ionic 4 app is running on Port 8100. I have also tried not including the <code>origins:</code></p>
  
  <p>my SocketService: </p>
  
  <pre><code>import { Socket } from 'ngx-socket-io';
  import { Observable } from 'rxjs';
  
  @Injectable({
    providedIn: 'root'
  })
      export class ChatService {
  
        constructor(private socket: Socket) {}
  
        public sendMessage(msg: any){
          this.socket.emit('new-message', msg);
  
        }
  
        public getMessages = () =&gt; {
          return Observable.create(observer =&gt; {
            this.socket.on('new-message', messageObj =&gt; {
              observer.next(messageObj);
            })
          })
        }
      }
  </code></pre>
  
  <p>What I am expecting it to do is connect, and for my server to register that there has been a connection.</p>
  
  <p>Thanks for any help</p>
  
  <p>UPDATE: I've configured my config.xml as such:</p>
  
  <pre><code>   &lt;content original-src="index.html" src="http://192.168.1.38:8100" /&gt;
      &lt;access origin="*" /&gt;
      &lt;allow-navigation href="*" /&gt;
  </code></pre>
  
  <p>no such luck. still blocked though</p>