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

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


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Hi @baljinderekrocx,

You’ll most probably have to change the hostname from localhost to 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' =>''

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

Regards, KFSys


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 in env configuration file in your magento root directory

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

Keep us posted, if this worked.

Cheers, Sri Charan