Error establishing a database connection WordPress

The most common reason for database connection error in WordPress is the database name and password and the server name. Login to your hosting server and access the file wp-config.php and download a copy to your desktop. Check the database login credentials and upload the file again. The issue that I had was the server name was changed in