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

timgavin's avatar

Can't Deploy

I just created a server and site on Forge, and now I'm trying to deploy from GitHub and I keep receiving the following error.

[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)  

Script php artisan optimize handling the post-install-cmd event returned with error code 1

I did not install a database on this server because I'm using a separate database server. I've tried deploying by updating the .env with the database credentials on the database server but it doesn't work; no matter what I do I receive that error message.

Do I need to have a database on this new server even though I'm not going to use it?

Edit: I have installed a database on this server, named it forge and added the user forge and it's still giving me the same problem.

0 likes
5 replies
willvincent's avatar

I've tried deploying by updating the .env with the database credentials on the database server

The .env file on your web server should contain all the proper credentials for connecting to your DB server.

mstnorris's avatar

You're trying to use 'forge'@'localhost' but you're saying that you're not using 'localhost', that you're using a database on another server. So you need to update the IP address of the database to suit.

timgavin's avatar

@willvincent, @mstnorris: I'm sorry, that was a clumsy sentence. I updated the .env file on my app server with the credentials for the database that exists on the database server.

DB_CONNECTION=mysql
DB_HOST=MY.DATABASE.SERVER.IP.ADDRESS
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=MY_DATABASE_SERVER_PASSWORD

I'm not trying to use forge@localhost, FORGE is trying to use forge@localhost.

I've tried deploying with an empty .env and with an edited .env and neither works. The only way I could get it to work was to deploy without installing composer dependencies, and then SSH into the server and run composer update

timgavin's avatar
timgavin
OP
Best Answer
Level 11

I figured it out; I actually had to hard code the database password in config/database.php and then deploy from Github on a clean site. Doesn't seem that's the right way to do it but it was the only way I could get it to work.

ShaneTurner's avatar

The default .gitignore file lists the .env as one of the files to ignore and not deploy. You need to re-create this file on your server.

Please or to participate in this conversation.