What do I put in the .env file?

The directions say:

  1. Copy the connection string. Select that you’d like to connect with the Mongo shell, version 3.6 or later . This will give you the srv connection string.
  2. Locate the file called dotenv_win or dotenv_unix (depending on your operating system) and replace the information within with your own srv connection string:

When I click “Connect via the Mongo Shell” it gives me the following:

mongo “mongodb+srv://mflix-4j0g1.mongodb.net/test” --username m220student

What exactly from this do I put into my .env file?

You should get the connection string for application which will be like:

That worked. Thank you!

For anyone else wondering, I actually clicked on “Connect Your Application” rather than “Connect with the Mongo Shell”

1 Like

BTW, for anyone using Windows, Windows will generally throw a hissy fit when you attempt to rename the file to .env. To get around this, just add a trailing period to the end of the filename, like so:


The Windows file system will then automatically strip the trailing period from the filename, leaving you with just a .env named file. This is an old file naming trick to get around the ‘file must have a name’ error in Windows when creating dot-named resource files.