title: MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms
body: <p>I am trying to create a fullstack app reading the following tutorial:</p>
  
  <p><a href="https://medium.com/javascript-in-plain-english/full-stack-mongodb-react-node-js-express-js-in-one-simple-app-6cc8ed6de274" rel="noreferrer">https://medium.com/javascript-in-plain-english/full-stack-mongodb-react-node-js-express-js-in-one-simple-app-6cc8ed6de274</a></p>
  
  <p>I followed all steps and then tried to run:</p>
  
  <pre><code>node server.js
  </code></pre>
  
  <p>But I got the following error:</p>
  
  <blockquote>
    <p>MongoDB connection error: MongoTimeoutError: Server selection timed
    out after 30000 ms
        at Timeout._onTimeout (C:\RND\fullstack_app\backend\node_modules\mongodb\lib\core\sdam\server_selection.js:308:9)
        at listOnTimeout (internal/timers.js:531:17)
        at processTimers (internal/timers.js:475:7) {   name: 'MongoTimeoutError',   reason: Error: connect ETIMEDOUT
    99.80.11.208:27017
          at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
        name: 'MongoNetworkError',
        [Symbol(mongoErrorContextSymbol)]: {}   },   [Symbol(mongoErrorContextSymbol)]: {} } (node:42892)
    UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection
    timed out after 30000 ms
        at Timeout._onTimeout (C:\RND\fullstack_app\backend\node_modules\mongodb\lib\core\sdam\server_selection.js:308:9)
        at listOnTimeout (internal/timers.js:531:17)
        at processTimers (internal/timers.js:475:7)</p>
  </blockquote>
  
  <p>My code at server.js is as follows:</p>
  
  <pre><code>const mongoose = require('mongoose');
  const router = express.Router();
  
  // this is our MongoDB database
  const dbRoute =
      'mongodb+srv://user:&lt;password&gt;@cluster0-3zrv8.mongodb.net/test?retryWrites=true&amp;w=majority';
  
  mongoose.Promise = global.Promise;
  
  // connects our back end code with the database
  mongoose.connect(dbRoute, 
      {   useNewUrlParser: true,
          useUnifiedTopology: true
      });
  
  let db = mongoose.connection;
  
  db.once('open', () =&gt; console.log('connected to the database'));
  </code></pre>
  
  <p>Any suggestions?</p>