title: Express can't start the server or connect to MongoDB
body: <p>I'm a beginner and try to create a rest API following <a href="https://www.mongodb.com/languages/express-mongodb-rest-api-tutorial" rel="nofollow noreferrer">this tutorial</a>. I expected to see <code>Server is running on port: ${PORT}</code>, but it seems like my code can't reach it. I got no error on my terminal and it looks like <a href="https://i.stack.imgur.com/wHUlJ.png" rel="nofollow noreferrer">this</a></p>
  <p>Here are my code:</p>
  <p>server.js</p>
  <pre><code>require('dotenv').config({ path: './config.env' });
  const express = require('express');
  const cors = require('cors');
  const dbo = require('./db/conn');
  
  const PORT = process.env.PORT || 5000;
  const app = express();
  
  app.use(cors());
  app.use(express.json());
  app.use(require('./api/api'));
  
  // Global error handling
  app.use(function (err, _req, res) {
    console.error(err.stack);
    res.status(500).send('Something broke!');
  });
  
  // perform a database connection when the server starts
  dbo.connectToServer(function (err) {
    if (err) {
      console.error(err);
      process.exit();
    }
  
    // start the Express server
    app.listen(PORT, () =&gt; {
      console.log(`Server is running on port: ${PORT}`);
    });
  });
  </code></pre>
  <p>conn.js</p>
  <pre><code>const MongoClient = require('mongodb').MongoClient
  const dotenv = require(&quot;dotenv&quot;)
  dotenv.config()
  
  const connectionString = process.env.MONGOURI
  let db;
  
  module.exports = {
    connectToServer : function(callback) {
      MongoClient.connect(connectionString, {
          useUnifiedTopology: true
        }, (err, client) =&gt; {
          if (err) return console.error(err)
      
          db = client.db('db-name');
          console.log('Connected to Database');
  
          return callback
       });
    },
  
    getDb: function () {
      return db;
    }
  }
  </code></pre>
  <p>api.js</p>
  <pre><code>const express = require(&quot;express&quot;);
  
  const gameRoutes = express.Router();
  
  const dbo = require('../db/conn');
  
  
  gameRoutes.route(&quot;/game&quot;).get(async function (_req, res) {
      const dbConnect = dbo.getDb();
  
      dbConnect
          .collection(&quot;game&quot;)
          .find({}).limit(50)
          .toArray(function(err, result) {
              if (err) {
                  res.status(400).send(&quot;Error fetching listings!&quot;);
              } else {
                  res.json(result);
              }
          })
      })
  
  module.exports = gameRoutes;
  </code></pre>
  <p>Can you please tell me what's wrong with my code? I really can't find why the server is not running. Thanks in advance! I'll be very grateful for your help!</p>