Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christopher's avatar

Forge - Laravel5 environment variables

I put in this variables to forge:

DB_HOST -> localhost
DB_DATABASE -> forge
DB_USERNAME -> forge
DB_PASSWORD -> forge password

But forge says that the mysql password does not match, but i gave the right value.

exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)' in /home/forge/default/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
Stack trace:

Do i take the wrong variables ?

0 likes
12 replies
jasonsleeman88@gmail.com's avatar

you have to create a .env file in the root of the application with the var's

DB_HOST=localhost
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=youpasswordhere

there is an example file that comes with a fresh install of laravel 5 .env.example

christopher's avatar

Yep i already created the .env file. locally it`s working fine - just with forge i have the problem

I dont think i have to create this file manually on the server or ? Because the .env file is of course in the gitignore. With laravel4 it was working fine :)

jasonsleeman88@gmail.com's avatar

please not that .env do not get uploaded to github/bitbucket, there are in the .gitignore file

jasonsleeman88@gmail.com's avatar
Level 18

you do need to create it manually on the server, or at least that's how i do it

1 like
christopher's avatar

okay if i create the .env manually on the server it`s working.

So - For laravel5 i actually dont need the env variables on forge right ? ( because you have to create the file manually )

bashy's avatar

.env files will need to be created manually (if they're in .gitignore) or correct, you can simply just add them in Forge.

1 like
jutarox's avatar

I am having the exact same issue, but the above doesn't seem to resolve anything for me. I've tried adding the env vars in forge, i've tried manually creating the .env.php file with the correct information. When I SSH in it says it's production, but when I run php artisan migrate it just continues to say the same error.

jutarox's avatar

5, I am able to connect via MySql Workbench just fine, laravel just doesn't seem to be taking my .env.php file in production

bashy's avatar

Laravel 5 uses .env not .env.php?

1 like

Please or to participate in this conversation.