title: How to use mongo/mongoose to connect to a remote database
body: <p>I have a node js app in IP ex: 111.111.111.23:3000 I want to connect from my local express/node app script to my remote mongodb database. the database is running in the IP mention above but for some reason all i can do is connect to my local mongodb databse.</p>
  
  <pre><code>if (app.get('env') === 'development') {
      app.use(function (err, req, res, next) {
          res.status(err.status || 500);
          res.render('error', {
              message: err.message,
              error: err
          });
      });
  
      mongoose.connect('mongodb://localhost/test');
  }
  </code></pre>
  
  <p>the code above is in my app.js and it works, but what I want to do is something like this.</p>
  
  <pre><code>if (app.get('env') === 'development') {
      app.use(function (err, req, res, next) {
          res.status(err.status || 500);
          res.render('error', {
              message: err.message,
              error: err
          });
      });
  
      mongoose.connect('mongodb:111.111.111.23:27017/test');
  }
  </code></pre>
  
  <p>I tried adding the ip with and without the port but it fails. </p>
  
  <p>My question is how do I connect to my remote database from my local machine ?</p>
  
  <p>it case this help. The remote server is running ubuntu server 14.04 and I installed mongodb using this guide: <a href="https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/" rel="noreferrer">https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/</a></p>
  
  <p>I get the following error:</p>
  
  <p>Error: connect ECONNREFUSED 111.111.111.23:27017</p>