Skip to content
Advertisement

Getting error mysqli::real_connect(): (HY000/2002): No such file or directory when I try to access my project on live server

I had uploaded my website to server and then I tried to access, but the code igniter returns me that error that I don’t find any answer. Why is this happening?

My config database is set like:

$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'netservice',
'password' => '*********',
'database' => 'valedastrutas',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
);

Advertisement

Answer

MySQL connection driver does not get any meaningful server at the location of localhost. So use,

'hostname' => '127.0.0.1' 

rather than

'hostname' => 'localhost'
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement