Report this

What is the reason for this report?

Error connecting droplet to database

Posted on December 11, 2024

Hello support, Currently I have one droplet and 2 Database Clusters in my account, Droplet is connecting to Database Cluster 1, but now I want droplet to connect to database 2, I have changed the connection information of database 2 in .env file in my laravel project, at the same time I also changed the database information in /etc/environment file and /root/.digitalocean_dbaas_credentials file but my project still connects to database 1, I don’t understand why, can you please provide documentation for me to handle this?



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!

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.

Heya,

That’s weird. Where is your Laravel Project deployed? Is it on a Droplet or on the App Platform?

Also, try giving a wrong password to see if you are still going to connect. If you do, then that means either the changes are not taking effect or the credentials are being taken from someplace else.

Heya, @v2vnit

Laravel may cache the .env file. After updating the .env file, clear and refresh the configuration cache. You can also try to connect to the dataabse to check if the login credentials are correct.

https://docs.digitalocean.com/products/databases/mysql/how-to/connect/

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.