title: What is mean by +srv in mongoDb connection string
body: <p>I am new to MongoDB and just encountered two types of connection string.</p>
  <ol>
  <li><p>mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]</p>
  </li>
  <li><p>mongodb+srv://[username:password@]host[/[database][?options]]</p>
  </li>
  </ol>
  <p>I know about the 1st one. But unfamiliar with the (+srv) in the 2nd.</p>
  <pre><code>   let connectionUrl;
        if (username &amp;&amp; password)
          connectionUrl = `mongodb://${username}:${password}@${host}:${
            port || 27017
          }/${databaseName}`;
        else
          connectionUrl = `mongodb://${host}:${
            port || 27017
          }/${databaseName}`;
        console.log(connectionUrl, &quot;connectionUrlconnectionUrl&quot;);
        let connection = await mongoose.createConnection(connectionUrl, {
          useNewUrlParser: true,
        });
        return connection;
  </code></pre>
  <p>Now the problem user can enter username, password, hostname, etc...</p>
  <p>But is there any way to know when to add  <em><strong>(+srv)</strong></em> because I was trying with localhost and with MongoDB atlas.
  Atlas works fine with +srv but in the case of localhost, it's throwing an error.</p>