Report this

What is the reason for this report?

SQLSTATE[HY000] [2002] No such file or directory - My Database is not connected

Posted on January 5, 2023

I followed all the steps to connect my database to my Laravel Application, including connecting to mysql using the terminal and using the connection parameters. I am able to see all of the database tables in the terminal. But, when I try to log into my application on the web, or run php artisan migrate, I get the following message: SQLSTATE[HY000] [2002] No such file or directory SELECT * FROM users WHERE email = info@example.com. I am assuming this is because my database is not connected.

Here are my .env values:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=username
DB_PASSWORD=protected

My app-level environment variables:
APP_NAME: App
APP_KEY: Key values
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 25060
DB_DATABASE: defaultdb
DB_USERNAME: username
DB_PASSWORD: password
APP_DEBUG: true
SSL_MODE: REQUIRED

Any help would be appreciated. Thank you.

The developer cloud

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

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.