title: MongooseError: The `uri` parameter to `openUri()` must be a string
body: <p>I have a problem with my code I used this code in 
  app.js:</p>
  
  <pre><code>const mongoose = require('mongoose'); 
  const dotenv = require('dotenv'); 
  dotenv.config()
  
    mongoose.connect(process.env.MONGO_URL) 
  .then(() =&gt; console.log("DB connected!"));
  
      mongoose.connection.on('error',function(err){   
  console.log("The error is: ");
  });
  </code></pre>
  
  <p>env.txt:</p>
  
  <pre><code>MONGO_URL=mongodb+srv://blur:blur@nodeapi-pfnvf8.mongodb.net/test?retryWrites=true
  PORT:8080
  </code></pre>
  
  <p>and for some reason it's giving me this weird error:</p>
  
  <pre><code>throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
      ^ MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
      at new MongooseError (C:\Users\razei\Desktop\Recat\project2\node_modules\mongoose\lib\error\mongooseError.js:14:11)
      at NativeConnection.Connection.openUri (C:\Users\razei\Desktop\Recat\project2\node_modules\mongoose\lib\connection.js:465:11)
      at Mongoose.connect (C:\Users\razei\Desktop\Recat\project2\node_modules\mongoose\lib\index.js:289:15)
      at Object.&lt;anonymous&gt; (C:\Users\razei\Desktop\Recat\project2\ap.js:9:10)
      at Module._compile (internal/modules/cjs/loader.js:701:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
      at Module.load (internal/modules/cjs/loader.js:600:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
      at Function.Module._load (internal/modules/cjs/loader.js:531:3)
      at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
      at startup (internal/bootstrap/node.js:283:19)
      at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) [nodemon] app crashed - waiting for file changes before starting...
  </code></pre>
  
  <p>can someone please help me I read a few posts but none of them helped </p>