title: ionic POST request error, net::ERR_CONNECTION_REFUSED
body: <p>i have an ionic app and i'm trying to test it on my android device. the app works when testing it on the browser using 'ionic serve' but when i run 'ionic run android' the post request does not seem to hit the server. I'm getting an error </p>
  
  <pre><code>'POST http://localhost:3000/login net::ERR_CONNECTION_REFUSED'
  </code></pre>
  
  <p>for the server i'm using nodejs and have access-control..</p>
  
  <pre><code>app.use(function (req, res, next) {
    res.header('Access-Control-Allow-Credentials', true);
    res.header('Access-Control-Allow-Origin', req.headers.origin);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header(
      'Access-Control-Allow-Headers', 
      'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept'
    );
    if ('OPTIONS' === req.method) {
      res.status(200).end();
    } else {
      next();
    }
  });
  </code></pre>
  
  <p>i've also installed cordova whitelist plugin and the meta content-security-policy like so..</p>
  
  <pre><code>&lt;meta http-equiv="Content-Security-Policy" content="default-src *; style-src *    'unsafe-inline'; script-src * 'unsafe-inline'; media-src *; img-src * data:;"/&gt;
  </code></pre>
  
  <p>but i'm still getting the same error. 
  i've also tried using my ip instead of localhost and got this error.</p>
  
  <pre><code>OPTIONS http://192.168.1.66:3000/login net::ERR_CONNECTION_TIMED_OUT
  </code></pre>
  
  <p>i've followed this thread..
  <a href="https://stackoverflow.com/questions/37062125/neterr-connection-refused-ionic">net::ERR_CONNECTION_REFUSED ionic</a>
  suggesting that i enable CORS by installing the microsoft.aspnet.webapi.cors.. i followed this link <a href="https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors" rel="nofollow noreferrer">https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors</a> and now i'm totally lost. please help, i've been on this for 3 days now.
  i appreciate all your help. thank you.</p>