Database connection error
Getting a database connection error, such as this one in Joomla, can be a scary thing to see on your website. It means that a program running on your site is not able to communicate with the MySQL database service to retrieve data. There are two main reasons for getting this error, either the program itself is not connecting properly due to login credentials mismatch from the program's configuration files, or the MySQL service is currently not running on the server. Below are instructions on how to check both.
Checking Program Configuration Files
If you have recently installed your program or changed the configuration options in the program, you will want to check to ensure the configuration files match what the database is expecting. The credentials you will need to know are the database name, host, database user name, and the database password.
First you will want to find these credentials in your program's configuration files. If you are unsure where these files are located for your program, you can check to see if the program is listed in our configuration files list article. Be sure to write down all the database credentials you find as you will need to check them against the server.
Once you have the credentials from the connecting program, you will need to check them against the server to make sure they are the same. The steps below will guide you on doing that.
- Log into your cPanel
- Locate the Databases category and click on the MySQL Databases icon.
- From the databases page you will see your databases in a list along with the database user in the column next to it.
- After confirming the database name and username, you will want to confirm the password. Since you cannot see the password, you will need to reset it by deleting the user and then recreating and attaching it to the database using the password from the configuration file.
If you have confirmed the credentials and are still getting the error, or the program was working and the database connection error suddenly began, it is possible the MySQL service is not running on the server at the moment. You can test this by running a test with something called Telnet. Telnet is a network protocol that you can use to connect to the server directly and check the service availability. Below are the steps to running a test with Telnet.
- Log into your command line interface. With a Windows machine you go to Start -> Run -> cmd. With Mac, you will need to open your Terminal application.
- Once in the command line interface, you will type the command telnet example.com 3306. (be sure to replace example.com with your own domain name). Here is the breakdown of the command: telnet is the command to tell the computer to use the telnet protocol. The domain name is telling which domain name/server to connect to, and the 3306 is the port for the MySQL service it will test. Below is an example of how your command should appear.
telnet example.com 3306
- Hit the enter key to activate the command. It will connect to the server using Telnet and test the port. If it is running, you will get a confirmation string beginning with the MySQL database version number.
If the MySQL service is not running, you will receive an error as below:
Connecting to example.com...Could not open connection to the host, on port 3306: Connect failed.
If you receive the connection failed error, the likely causes of service unavailability are either a temporary high load on the server, or the service is being restarted by the Systems Administration team. This should clear up within a few minutes. If you receive the connection confirmation and are still receiving the error, you will want to contact our Live Support team for further assistance.
Thank you for your feedback!