Question

SQLSTATE[HY000] [2002] No such file or directory

Posted February 3, 2021 5.3k views
MySQLPHPUbuntu 18.04

SQLSTATE[HY000] [2002] No such file or directory:
This error keeps poping up. I have installed magento 2.3.5 version
Please let me know how to fix this error

Thanks

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.

×
Submit an Answer
2 answers

Hello,

Once, can you check if the MySQL service is up and running. If it is down, you will need to restart.

service mysql start

You also may have to change the hostname from localhost to 127.0.0.1 in env configuration file in your magento root directory

Open app/etc/env.php
change 'host' => 'localhost' to 'host' =>'127.0.0.1'
Save file and retry

Keep us posted, if this worked.

Cheers,
Sri Charan

Hi @baljinderekrocx,

You’ll most probably have to change the hostname from localhost to 127.0.0.1 in the env configuration file of your Magento application.

First, go to your Website’s DocumentRoot

cd /path/to/website

Once inside open the config file

nano app/etc/env.php

In there you’ll find an enviroment called host, change it like so

change 'host' => 'localhost' to 'host' =>'127.0.0.1'

Save the file and reload the website to see if the error is still being experienced.

Regards,
KFSys