title: Mongoose query works perfect on Windows 10, but hangs on Ubuntu 18.04
body: <p><strong>Context</strong></p>
  
  <p>I've developed a React system and the login is handled by an API that hands out JWT tokens. I've developed everything on Windows 10 and I will deploy it on a EC2 Ubuntu 18.04 LTS unit.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>The API runs on Express. The app is able to make a DB connection (which is hosted on MongoDB Atlas) on both Windows and Linux (even though it takes much longer on Linux). However, the app is not able to make a query. The find or findOne functions both don't give any feedback, while they work perfectly fine on my Windows machine.</p>
  
  <p><strong>The relevant code</strong></p>
  
  <p>The code is as follows:</p>
  
  <p><em>App.js</em></p>
  
  <pre><code>const createError = require('http-errors');
  const express = require('express');
  const app = express();
  const path = require('path');
  const cookieParser = require('cookie-parser');
  const logger = require('morgan');
  const cors = require('cors');
  const mongoose = require('mongoose');
  const dotenv = require('dotenv');
  
  dotenv.config();
  
  //Connect to DB
  mongoose.connect(process.env.DB_CONNECT, {useNewUrlParser: true, useUnifiedTopology: true}, () =&gt; {
      console.log("Connected to DB!");
  });
  
  //Import routes
  ...
  const authentication = require('./routes/Auth');
  ...
  
  //Middleware
  app.use(cors());
  app.use(logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded({extended: false}));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  //Route middleware
  ...
  app.use('/auth', authentication);
  ...
  
  // catch 404 and forward to error handler
  app.use(function (req, res, next) {
      next(createError(404));
  });
  
  // error handler
  app.use(function (err, req, res, next) {
      // set locals, only providing error in development
      res.locals.message = err.message;
      res.locals.error = req.app.get('env') === 'development' ? err : {};
  
      // render the error page
      res.status(err.status || 500);
      res.render('error');
  });
  
  app.listen(3003, () =&gt; {
      console.log("server is up and running");
  });
  module.exports = app;
  </code></pre>
  
  <p><em>Auth.js</em></p>
  
  <pre><code>const router = require('express').Router();
  const User = require('../model/user');
  
  const jwt = require('jsonwebtoken');
  const bcrypt = require('bcryptjs');
  const {registerValidation, loginValidation} = require('../model/Validation');
  
  ...
  
  router.post('/login', async (req, res) =&gt; {
      //Validate the data
      const {error} = loginValidation(req.body);
      if(error) return res.status(400).send(error.details[0].message);
  
      //Check if exists
      //Application fails here
      const user = await User.findOne({email: req.body.email}, function (err) {console.log(err)});
      if(!user) return res.status(400).send('Email or password is wrong');
  
      //Check if password is correct
      const validPass = await bcrypt.compare(req.body.password, user.password);
      if(!validPass) return res.status(400).send('Email or password is wrong');
  
      //Create and assign a token
      const token = jwt.sign({_id: user._id}, process.env.TOKEN_SECRET, { expiresIn: 60 * 240});
      res.header('auth-token', token).send(token);
  })
  
  ...
  
  module.exports = router;
  </code></pre>
  
  <p><em>user.js (the model)</em></p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const userSchema = new mongoose.Schema({
      name: {
          type: String,
          required: true,
          max: 255
      },
      email: {
          type: String,
          required: true,
          max: 255
      },
      password: {
          type: String,
          required: true,
          max: 1024,
          min: 6
      },
      date: {
          type: Date,
          default: Date.now
      }
  });
  
  module.exports = mongoose.model('User', userSchema);
  </code></pre>
  
  <p><strong>What I've done</strong></p>
  
  <ul>
  <li>I've checked for errors, but can't seem to find any.</li>
  <li>I've checked the connection, and it is able to connect to the server.</li>
  <li>I've changed the connection parameters, which did not change any behaviour. </li>
  </ul>
  
  <p><strong>My goal</strong></p>
  
  <p>I want to be able to run the API on my Linux Ubuntu VPS so I can deploy the actual React application. Right now the login obviously doesn't work. All the other endpoints in the API (has a lot of functions / endpoints, but these not related to either the login endpoint or MongoDB) are working perfectly fine.</p>