title: I am trying to connect my server.js express api from mongodb but it showing some error i don't understand it
body: <p><code>Here is my code of server.js</code></p>
  <pre><code>    import express from 'express';
      
      import bodyParser from 'body-parser';
      
      import userRoutes from './routes/users.js';
      
      import mongoose from 'mongoose';
      
      const app = express();
      const PORT = 4000;
      
      app.use(bodyParser.urlencoded({ extended: true }));
      
      app.use('/users', userRoutes);
      
      mongoose.Promise = global.Promise;
      
      mongoose.connect(&quot;mongodb://localhost:27017/articlesdb&quot; ,{
          useNewUrlParser: true
        })
        .then(() =&gt; {
          console.log(&quot;database connected&quot;);
        })
        .catch(err =&gt; {
          console.log(&quot;Could not connect&quot;, err);
        });
        
      app.get('/', (req, res) =&gt; {
          console.log('[TEST]!');
          res.send('Hello from homepage.');
      });
      
      app.listen(PORT, () =`enter code here`&gt; console.log(`Server is Running on port: http://localhost:${PORT}`));
  </code></pre>
  <p>And I am getting this error:
  Could not connect MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
  at Connection.openUri (D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\connection.js:824:32)
  at D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\index.js:381:10
  at D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
  at new Promise ()
  at promiseOrCallback (D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
  at Mongoose._promiseOrCallback (D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\index.js:1234:10)<br />
  at Mongoose.connect (D:\Vue Practice Project\instant-search-project\node_modules\mongoose\lib\index.js:380:20)
  at file:///D:/Vue%20Practice%20Project/instant-search-project/server.js:27:10
  at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
  at async Promise.all (index 0) {
  reason: TopologyDescription {
  type: 'Unknown',
  servers: Map(1) { 'localhost:27017' =&gt; [ServerDescription] },
  stale: false,
  compatible: true,
  heartbeatFrequencyMS: 10000,
  localThresholdMS: 15,
  setName: null,
  maxElectionId: null,
  maxSetVersion: null,
  commonWireVersion: 0,
  logicalSessionTimeoutMinutes: null
  },
  code: undefined
  }`</p>