title: httpclient get gives ::ERR_CONNECTION_REFUSED on using ng serve
body: <p>When I start the development Node server with ng serve.
  and type in the below address, it works.</p>
  
  <pre><code>http://localhost:4200/login       
  </code></pre>
  
  <p>However when I type in my username and password it gives me the below error in the console.</p>
  
  <pre><code> OPTIONS http://localhost:3000/api/findCoinData?_id=5a1b2d9a6e915f5838ae5a50 
   net::ERR_CONNECTION_REFUSED
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code> ng serve --host 0.0.0.0
  
   ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true 
  </code></pre>
  
  <p>Keep getting the same error, I have a feeling this problem happens due to the localhost setting, but changing it to the local IP didn't solve the issue.</p>
  
  <p>Anyone has any idea what could be going wrong here?</p>
  
  <p>All works when I use: </p>
  
  <pre><code>npm start
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code> var express = require('express');
   var path = require('path');
   var favicon = require('serve-favicon');
   var logger = require('morgan');
   var cookieParser = require ('cookie-parser');
   var session = require ('express-session');
   var bodyParser = require('body-parser');
   var morgan = require ('morgan');
   var mongo= require('mongodb');
  
  
   var mongoose = require('mongoose');
   var flash = require('connect-flash');
   var chat = require('./server/routes/chat');
   var connect = require('./models/user')
    //var cors = require('cors');
    connect.connect('mongodb://localhost/loginapp');
   var db = mongoose.connection;
  
    var passport = require ('passport');
    //var LocalStrategy = require ('passport-local').LocalStrategy;
  
     var Schema = mongoose.Schema;
  
  
    var config = require ('./config/database');
   var engines = require('consolidate');
  
  
   var router = express.Router();
   var api = require('./server/routes/api');
   var app = express();
   app.use(logger('dev'));
   //app.use(cors());
  
  // directories that are publicly accesible through the browser.
  app.use(express.static(path.join(__dirname, 'dist')));
  app.use(express.static(path.join(__dirname, 'public')));
  
   app.use(cookieParser());
   app.use(morgan('dev'));
   app.use(session({
  secret: 'secret123',
  resave: true,
    saveUnitialized: true
    }));
  
   app.use(bodyParser.json());
   app.use(bodyParser.urlencoded({'extended':'true'}));
  
   //initialise always before session!
   app.use(passport.initialize());
   app.use(passport.session());
   app.use(flash());
   //set viewing engine
  
   app.use('/api', api);
   //app.get("/test", findAllMessages);
   app.get('*', (req, res) =&gt; {
  
  res.sendFile(path.join(__dirname, 'dist/index.html'));
  
  
     });
  
   // global variables flash
     app.use(function(req,res, next) {
  res.locals.succes_msg = req.flash('succes_msg');
  res.locals.error_msg = req.flash('error_msg');
      res.locals.error = req.flash('error');
  res.locals.user = req.user || null;
  next();
      });
  
  
     module.exports = app;
  </code></pre>