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

gregpmillr's avatar

Deployment Incorrect DB Connection Credentials

'Ello, wondering if anyone's ever encountered this one:

Setup laravel forge on a vps from digital ocean, got it all deployed and the website works, but I cannot access my mysql db. It connects successfully but is trying to input the incorrect credentials for access. It's attempting to connect with my previous login credentials from when I was developing locally. It's using my old localhost instead of my new ip, old username, password, etc etc. I've updated the .env file and .env.example just to see if it'd change anything, and I've updated the config/database.php file to try to access it from env variables and I've also tried to hard-code it without success - Still tries to login with my old credentials. I couldn't install my repo to my server via forge so may that have something to do with it? I'm at a loss for this one.

Thanks!

0 likes
9 replies
ejdelmonico's avatar

You added your correct .env info into Laravel forge right? And, hopefully, you are NOT committing your .env file to repository. If you go to Meta tab you can add your key manually to github or bitbucket in case that is your issue.

gregpmillr's avatar

My git repository would not work with forge, and I believe it's the problem (can't edit .env file because it clears itself. I'm guessing because the repo isn't installed on my site ) Whenever I try to install, I get the error

Cloning into 'PrintShopTest'... Composer could not find a composer.json file in /home/forge/PrintShopTest To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

composer.json is definitely in the git repository. Tried looking for the deploy script to change its directory but I'm not able to find it on the site settings anywhere

ejdelmonico's avatar

Let me understand you. You are not hosting your repo on github or bitbucket and you ssh in to the server and cloned your repo?

gregpmillr's avatar

I have my repo on Github, I ssh into the server, try and use forge to install the git repo onto my server and it gives that error above.

When I clone my repository manually it works, but when I do this, I cannot edit the .env file on forge to change the db connection credentials (guessing because it wasn't installed from forge) .

ejdelmonico's avatar

Did you add your github repo under manage site and then the App tab? If that doesn't prompt you to connect then you may have to add the server public key manually. You can find that under server meta tab.

gregpmillr's avatar

Yes I added it under manage site -> app tab via ssh. Oddly enough the public key is added, I have no problems with it getting access to the repo, it just seems like it may be looking in the wrong directory for composer.json

ejdelmonico's avatar
Level 53

Yes, that is probably the issue. It is looking one level up from the public folder for everything that is not public. It should still let you artisan migrate and then add the .env in the edit files dropdown.

gregpmillr's avatar

Alrighty I'll go with it that way then. Thanks for all the help my friend! Any idea how to change where it's looking for the composer.json? If not that's fine - At least it's working now :P

Please or to participate in this conversation.