title: My terminal is showing error for following code
body: <p><strong>ERROR</strong></p>
  <p>*<code>Server started on port 4000 Database ErrorMongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 (node:1616) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 at NativeConnection.Connection.openUri (C:\Users\HARSH KUMAR SHARMA\Desktop\MEAN\node_modules\mongoose\lib\connection.js:845:32) at C:\Users\HARMA\Desktop\MEAN\node_modules\mongoose\lib\index.js:345:10 at C:\Users\HARMA\Desktop\MEAN\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5 at new Promise (&lt;anonymous&gt;) at promiseOrCallback (C:\Users\HARSH KUMAR SHARMA\Desktop\MEAN\node_modules\mongoose\lib\helpers\promiseOrCallback.js:30:10) at Mongoose._promiseOrCallback (C:\Users\HARMA\Desktop\MEAN\node_modules\mongoose\lib\index.js:1135:10) at Mongoose.connect (C:\Users\HARMA\Desktop\MEAN\node_modules\mongoose\lib\index.js:344:20) at Object.&lt;anonymous&gt; (C:\Users\HARMA\Desktop\MEAN\app.js:10:10) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 (Use</code>node --trace-warnings ...<code>to show where the warning was created) (node:1616) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag*</code>--unhandled-rejections=strict` (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow noreferrer">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>). (rejection id: 1)
  <em>(node:1616) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</em></p>
  <p><strong>app.js</strong> File</p>
  <pre><code>const express = require('express');
  const path = require ('path');
  const bodyParser = require('body-parser');
  const cors = require('cors');
  const passport  = require('passport');
  const mongoose = require('mongoose');
  const config = require('./config/database');
  
  // Connect to Database
  mongoose.connect(config.database, {useNewUrlParser:true , useUnifiedTopology:true}); 
  
  // On Connection
  mongoose.connection.on('connected' , ()=&gt;{
      console.log('Connected to DataBase' + config.database);
  });
  
  // On Error
  mongoose.connection.on('error' , (err)=&gt;{
      console.log('Database Error' + err);
  });
  
  const app = express();
  
  const users = require('./routes/users');
  
  // Port Number
  const port = 4000 ;
  
  // CORS Middleware
  app.use(cors());
  
  //Set Static Folder
  app.use(express.static(path.join(__dirname , 'public')));
  
  //bodyParser Middleware
  app.use(bodyParser.json());
  
  app.use('/users' , users);
  
  //INDEX Route
  app.get('/' , (req ,res) =&gt; {
      res.send('invalid Endpoint');
  })
  
  // Start Server  
  app.listen(port , () =&gt; {
      console.log('Server started on port ' + port);
  })
  
  </code></pre>
  <p><strong>database.js</strong>  File</p>
  <pre><code>module.exports = {
      database: 'mongodb://localhost:27017/meanauth',
      secret : 'yoursecret'
  };
  
  </code></pre>