Laravel DB Connection refused

Hello all, I’m running into what I assume is a trivial issue with deploying my laravel app but I cannot figure out the actual problem.

I have a “php artisan migrate --force” background process, I have my env variables set from my .env file

however whenever I deploy, my logs show the following:

In Connector.php line 65:
Mar 02 09:57:43                                                     
Mar 02 09:57:43   SQLSTATE[HY000] [2002] No such file or directory  
Mar 02 09:57:43                                                     
Mar 02 09:57:43 
Mar 02 09:59:14 
Mar 02 09:59:14 In Connection.php line 829:
Mar 02 09:59:14                                                                                
Mar 02 09:59:14   SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: s  
Mar 02 09:59:14   elect table_name as `name`, (data_length + index_length) as `size`, table_c  
Mar 02 09:59:14   omment as `comment`, engine as `engine`, table_collation as `collation` fro  
Mar 02 09:59:14   m information_schema.tables where table_schema = 'blog' and table_type in (  
Mar 02 09:59:14   'BASE TABLE', 'SYSTEM VERSIONED') order by table_name)                    

is there something obvious im doing wrong?

my .env variables are:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=username_Im_not_going_to_actually_write_here
DB_PASSWORD=password_Im_not_going_to_actually_write_here

Hi @chelski! Welcome to the Kinsta community!

Thanks for reaching out to us! I’m sorry to see that you are experiencing difficulty with connecting to the database on your Laravel application. We’re happy to help!

It looks like this type of issue is typically caused when the database service is not running, or is not installed. To clarify, are you attempting to run the database service locally on the same application container as your Laravel application? Or, have you created a separate database through our Database Hosting service and are trying to connect it to the application for it to use?

If you could also please private/direct message me the domain name of your application that will allow us to locate it on our backend. That will allow us to review all of the logs, and review the services on the container.

We look forward to hearing back from you!

Best regards

Hi @chelski!

Thank you for following up in a direct message! I have located your application, and reviewed the logs. I see it appears the error message has changed at this point with your latest deployments. I see now it looks like a permission denied error occurs.

I have reviewed your application’s repository, and I do see it appears that the username, DB_HOST, DB_DATABASE and DB_PORT are defined in the database configuration file. However, it looks like those environment variables are already set in MyKinsta. I would recommend trying to remove the username, DB_HOST, DB_DATABASE and DB_PORT values set in the database configuration file to ensure that it is not overriding the values set in MyKinsta.

Also, please do double check all of the environment variables configured within MyKinsta to ensure that they are correct and match the database.

If you do continue to have any difficulty after removing the values from the database configuration file, or have any other questions please don’t hesitate to reply! We are always happy to help!

Best regards