title: Node.js "Error: read ECONNRESET"
body: <p>I am trying to connect to mongo via Node.js and I'm getting the following error:</p>
  
  <pre><code>connection error: { Error: read ECONNRESET
  at exports._errnoException (util.js:1022:11)
  at TCP.onread (net.js:610:25) name: 'MongoError', message: 'read ECONNRESET' }
  (node:3868) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: read ECONNRESET
  </code></pre>
  
  <p>Here is the code I'm using to connect:</p>
  
  <pre><code>const mongoose = require('mongoose');
  mongoose.Promise = global.Promise;
  
  module.exports = (config) =&gt; {
  
          const fs = require('fs');
  
          let key = fs.readFileSync('../server/test/keys/cert_key.pem');
          let ca = [fs.readFileSync('../server/test/keys/ca.pem')];
  
          let o = {
              server: {
                  sslValidate: true,
                  sslCA: ca,
                  sslKey: key,
                  sslCert: key
              }
          };
          mongoose.connect(config.connectionString, o);
  
  
      let database = mongoose.connection;
  
      database.on('error', console.error.bind(console, 'connection error:'))
  
      database.once('open', (error) =&gt; {
          if (error) {
              console.log(error);
              return;
          }
  
          console.log('MongoDB ready!')
      });
  
      require('./../models/Role').initialize();
      require('./../models/User');
      require('./../models/Item');
      require('./../models/character/Character_item');
      require('./../models/Article');
      require('./../models/Friend_request');
      require('./../models/Code');
      require('./../models/Ring');
      require('./../models/Ring_shop');
      require('./../models/Comment');
  };
  </code></pre>
  
  <p>If I try to connect to mongo from Robo3T, it works. So it seems the problem is in my Node code. Any suggestions?</p>