title: how can i connect to other hosts other than localhost in nodejs while making connection to the database
body: <p>Nodejs working only with localhost while making connection to the mysql database.how can i connect to other hosts?</p>
  
  <p>this is my code</p>
  
  <pre><code>var mysql=require('mysql');
  var express=require('express');
  const app=express();
  var bodyParser=require('body-parser');
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({
      extended:true
  }))
  app.get('/',function(req,res) {
          return res.send({error:true,message:'working'});
  })
  app.listen(8080,function() {
          console.log('port listening on 8080');
  })
  const mc=mysql.createConnection({
          host:'localhost',
          user:'root',
          password:'root',
          database:'test'
  })
  mc.connect();
  app.get('/users',function(req,res) {
      mc.query('select * from sample1',function(err,results) {
              if(err) throw err;
              console.log(({status:200,data:results}));
              return res.send({status:200,data:results});
      })
  })
  app.post('/userslist',function(req,res) {
      var id=req.body.id;
      console.log(id);
      return res.send(id);
  })
  </code></pre>
  
  <p>when i change the host address it shows some error</p>
  
  <pre><code>port listening on 8080
  events.js:137
        throw er; // Unhandled 'error' event
        ^
  
  Error: connect ECONNREFUSED 192.168.1.10:3306
      at Object._errnoException (util.js:1003:13)
      at _exceptionWithHostPort (util.js:1024:20)
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
      --------------------
      at Protocol._enqueue (/var/www/html/nodejs/node_modules/mysql/lib/protocol/Protocol.js:145:48)
      at Protocol.handshake (/var/www/html/nodejs/node_modules/mysql/lib/protocol/Protocol.js:52:23)
      at Connection.connect (/var/www/html/nodejs/node_modules/mysql/lib/Connection.js:130:18)
      at Object.&lt;anonymous&gt; (/var/www/html/nodejs/index.js:21:4)
      at Module._compile (module.js:660:30)
      at Object.Module._extensions..js (module.js:671:10)
      at Module.load (module.js:573:32)
      at tryModuleLoad (module.js:513:12)
      at Function.Module._load (module.js:505:3)
      at Function.Module.runMain (module.js:701:10)
  </code></pre>
  
  <p>i don't know for what reason this error is shown .how can i get rid of this issue ?</p>