title: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
body: <p>Invalid scheme, expected connection string to start with &quot;mongodb://&quot; or &quot;mongodb+srv://&quot;</p>
  <p>I am using MongoDB atlas</p>
  <p>Index.js</p>
  <pre><code>import bodyParser from &quot;body-parser&quot;;
  import mongoose from &quot;mongoose&quot;;
  import cors from &quot;cors&quot;;
  import postRoutes from &quot;./Routes/posts.js&quot;;
  import dotenv from &quot;dotenv&quot;;
  
  const app = express();
  dotenv.config();
  
  app.use(bodyParser.json({ limit: &quot;50mb&quot;, extended: true }));
  app.use(bodyParser.urlencoded({ limit: &quot;50mb&quot;, extended: true }));
  app.use(cors());
  
  app.use(&quot;/posts&quot;, postRoutes);
  
  const PORT = process.env.PORT || 4000;
  
  mongoose
  .connect(process.env.CONNECTION_URL, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  })
  .then(() =&gt; {
  app.listen(PORT, console.log(Server is running on port ${PORT}));
  })
  .catch((err) =&gt; console.log(err.message));
  </code></pre>
  <hr />
  <p>.env file</p>
  <pre><code>CONNECTION_URL =
  &quot;mongodb+srv://&lt;UserName&gt;:&lt;Password&gt;@cluster0.v5qzigz.mongodb.net/?retryWrites=true&amp;w=majority&quot;;
  
  PORT = 4000;
  </code></pre>
  <hr />
  <p>it works fine if i do not use .env File. Process.env.CONNECTION_URL is not working ?</p>