sony
sony

Reputation: 11

Error establishing a database connection in wordpress or we can’t contact the database server at localhost

My wordpress site showing error establishing database connection even after giving the correct database name, username, password and db_host. I got this error when I load my site.

" This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down. "

Upvotes: 0

Views: 2009

Answers (2)

thilinaj
thilinaj

Reputation: 379

Make sure your DB user has the proper privileges to connect from the localhost. If the existing DB user doesn't have the hostname field as the localhost, edit the existing user, or create a new user with the localhost as the hostname.

Upvotes: 0

R.K.Bhardwaj
R.K.Bhardwaj

Reputation: 2192

Login to Cpanel or FTP then edit your wp-config.php file enable there debug mode :

define( 'WP_DEBUG', true );

define('WP_ALLOW_REPAIR', true);

You will get the report of front end fix it if any error occurring there

define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost');

recheck your database username, password, database name and host name

some time the SPACE creating problems

Thanks

Upvotes: 1

Related Questions