The environment file is invalid: Dotenv values containing spaces must be surrounded by quotes

Hello everyone I need help regarding this error message: “The environment file is invalid: Dotenv values containing spaces must be surrounded by quotes”

I just finished setting up environment for my app according to the request of the wizard installer of the app. I input things like database credentials, mail credentials, google client ID and others. After that, upon visiting my website, I found this error. That made me to remember that when I was filling the forms, I spaced out my username when entering the mail credentials, so I don’t know if that is part of my problem now.

So, how do I access the Dotenv file according to the error instruction to check the files with spaces and correct them? OR Which command will I use to get rid of this once and for all?

In fact, how do I solve this problem?

Thanks, everyone. looking forward to hearing from you.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Would you mind confirming which application exactly did you deploy? I can then confirm the exact location of the Dotenv file and the exact steps that you need to take to fix it.

But for example if you are using Laravel the default location of the .env file is at:


You need to open this file with your favorite text editor and find the username line:

nano /var/www/html/.env

Find the user name variable and add quotes around the value.

Regards, Bobby