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

renec112's avatar

Access denied for user 'forge'@'localhost' (using password: NO)

Hi - I'm trying to deploy my laravel with App with forge.

However, i get the following error:

Access denied for user 'forge'@'localhost' (using password: NO)  

I'm using digital ocean and forge created the droplet by it self. I think the error is from the database.php - But i'm not sure what's wrong. Does this looks ok?

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

        'pgsql' => [
            'driver'   => 'pgsql',
            'host'     => env('DB_HOST', 'localhost'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
        ],

        'sqlsrv' => [
            'driver'   => 'sqlsrv',
            'host'     => env('DB_HOST', 'localhost'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset'  => 'utf8',
            'prefix'   => '',
        ],

Also i'm experiencing some issues, when i try to connect to the database using mySql workbench - i can't connect with the information on the email, i've tried with multiple droplets.

Would love your input !! :)

0 likes
6 replies
tykus's avatar

Have you created a .env or set the correct environment variables in Forge?

renec112's avatar

Hm - no my env settings in forge is empty. I thought forge did that.. whoops :p

But thank you @tykus_ikus :) ! after googling a bit, i'm getting different results on how to setup these variables. How would you do it Tykus? thank you for the help.

tykus's avatar

The .env file is outside version control so will not be deployed along with your code. I usually will SSH into the server and copy my .env keys from development; with the production-specific values. There is a GUI for this in Forge also, under the site's Environment tab.

renec112's avatar

Thanks @tykus_ikus - I tried doing that on a second dropplet. and it actually worked!

Thanks man :)

I've gotten a new error. I expernced that on another dropplet, but i didn't manage to fix it. Can you help? This is the error that my server outputs with DEBUG = true:

No supported encrypter found. The cipher and / or key length are invalid.

To fix that i tried cloning the git, doing "Php artisan key generate" and uploaded that back to the server. Also i copyed they generated key, and put it inside the envirement settings on forge under APP_KEY.

Am i missing something? My key ends with a "=" Equal to sign, seems a bit weird to me though.

Man i really appreciate your help. Thank you.

tykus's avatar
tykus
Best Answer
Level 104

So, just to confirm:

  • You have generated a key using php artisan key:generate?
  • This key is in your .env file under a APP_KEY key?
  • Your config/app.php has a key 'key' => env('APP_KEY')?

If all of these are in place you should be right. Come back if there are any errors.

4 likes

Please or to participate in this conversation.