InMotion Hosting Support Center

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.

  1. Log into your cPanel
  2. Locate the Databases category and click on the MySQL Databases icon.
  3. From the databases page you will see your databases in a list along with the database user in the column next to it.
  4. 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.

Telnet Test

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.

Note that newer versions of Windows do not have the Telnet service enabled by default. You may have to enable it before running this test. You can find instructions on how to do this in our article on enabling telnet on a Windows computer.
  1. 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.
  2. 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
  3. 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.

    5.1.66-c115btB+Q...

    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.

Support Center Login

Social Media Login

   
Social Login Joomla
n/a Points
2014-07-08 3:33 am
Re write your tutorials covering common errors
Staff
14,838 Points
2014-07-08 10:51 am
Hello Enrique,

Thank you for your feedback. This is a pretty standard guide, and I did not see any errors withing the article. We are happy to help you, but will need some additional information.

What problems are you having?

Is there a step or section here that is not working for you?

Can you provide a link to the database connection error you are having?

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
n/a Points
2014-09-06 5:10 am
When we get this error:
Error establishing a database connection
It also means that cpanel is not working so making the changes on cPanel as described is impossible
Staff
25,627 Points
2014-09-21 11:25 am
Hello Paul,

If you cannot access the cPanel, it is possible the MySQL service itself is down. To test that you would run the Telnet Test that is discussed in the second portion of the article.

Kindest Regards,
Scott M
n/a Points
2015-02-25 11:59 pm

Hi this 

Error establishing a database connection

 

Seems to be happend a couple of times and the chat staff said your server is down..

 

Can please help to resolve asap.

 

Thanks

Staff
23,356 Points
2015-02-26 9:56 am
Hello Belle,

Sorry for the database issues. If the server was reported down, then the database connection would not work. However, as per the support ticket in your account, it does look as they have fixed the issue for you. If you continue to have any further problems, please let us know.

Regards,
Arnel C.
Staff
25,627 Points
2015-02-26 10:03 am
Hello Belle,

You are on a server that is currently having MYSQL service issues. Our Systems team is working hard to get that back up as quickly as possible for you.

Kindest Regards,
Scott M
n/a Points
2015-02-26 10:36 am

Hi Arnel and Scott,

 

Thanks for responding to me.

I have spoken to 3 of your staff and they all say different things...

1) Host server is down.

2) Host server is not down but my Cloudproxy settings are causing the problem.

Could a technician please help me look into the issue and let me know please..

 

Thanks in advance

Belle

Staff
25,627 Points
2015-02-26 12:19 pm
Hello Belle,

The MySQL service issue was fixed on the server, so that should no longer be a factor. The tempURL seems to work and if the domain has been pointed to us recently, then it could still be showing cached information from the CDN. This may take some time to propagate out.

Kindest Regards,
Scott M
n/a Points
2015-02-26 12:25 pm

Hi Scott,

Actually only my main page http://www.catalogue.com.sg shows the error message.

My other pages are fine.

Why is this so?

Can you help me look into the issue please.

Thanks

Belle

Staff
25,627 Points
2015-02-27 8:25 am
Hello Belle,

It appears the site just needed the time to get rid of the cloudproxy cache and propagation to the server itself. I am showing your site quite fine now and am not getting any errors.

Kindest Regards,
Scott M
2015-03-10 9:53 am
I have been having a ton of connection errors (too many connections, can't fetch mysqli, and others) and they can't seemed to be fixed. I am told it is an OpenCart problem but I couldn't connect to my Wordpress site last night on the same server. Why is that? I did the Telnet yesterday and could not connect to my site. Plus when I have made changes and refreshed my site, the site doesn't load the colors/template properly at times.

They just changed my PHP version to the previous one. Now today I can't add pictures that are already uploaded or make any changes at all and keep getting all those connection errors.

What can be done? I am at a loss. I need to have this resolved or I can't launch my website.

Thanks,
Diana
Staff
2,274 Points
2015-03-10 11:53 pm
Hello Diana,

Generally the problem comes from software opening connections to mysql and not closing them in a timely manner. The reason your wordpress website was not working was most likely due to your account using all of the allotted mysql space each account is allowed. What is your domain so we may try to troubleshoot further.

Best Regards,
TJ Edens
2015-03-11 9:38 am
www.christiancoverings.com

I have found out from support that the max user connects is set to 30.
Also doing some research on OpenCart forum shows it is a server problem and not an OpenCart problem. I have read it should be: max_connections = 1000
max_user_connections=200
(this is a system wide mysql variable)
Most are 500/100.
Staff
23,356 Points
2015-03-12 10:40 am
Hello Dm5400,

Setting max connections to 1000 doesn't solve the issue of why several hundred connections to the database are required by OpenCart. If you want to make that change, it would be better suited to using the installation in a VPS or Dedicated server environment where resources can be more focused to the application. Making these type of changes in a shared server environment can lead to problems with resource usage. If you have a plugin that is requiring that many open database connections, it should not be recommended for shared server use. Also, if you consider that database connections are usually made in conjunction with the number of users in the applications, having several hundred open at the same time should only be made if you have that many concurrent users in the application. If you're seeing that kind of traffic, then you should definitely not be on a shared server.

Database connections are not typically held open. They are opened, then shut as soon as a query or update is made. Requiring many concurrent database openings for minimal application use is indicative of an issue that the developer should correct. In the case of OpenCart, I would recommend you review your plugins/extensions. Our web design team uses it for many of our clients, and the max connections setting is never an issue.

Regards,
Arnel C.

2015-03-12 10:54 am
I am new to OpenCart. The only extension I have is a total based shipping extension by clearthinking. I am using the Journal responsive theme made for OpenCart (modified to suit my simple design). That is it. I do not have a large store nor do I have a lot of traffic to my site. I have always been on a shared server and never had any issues with my site. I have been in contact with the theme support and according to them, it would not cause these issues. I have been able to work on my site the past two days without any error messages, etc. so it's not everyday I see them.
n/a Points
2015-03-27 3:58 pm

I am getting the error: "Failed to connect to the database" - tried the the Telnet Test and I am getting the following message:

Mac-0026b0ef185e:~ w16141$ telnet strategicanalytics-cip.com 3306

Trying 173.247.252.218...

Connected to strategicanalytics-cip.com.

Escape character is '^]'.

N

5.6.21-logb;MN#bDm?7F:1&fTPtvvmmysql_native_passwordConnection closed by foreign host.

Any help will be appreciated!

 

Carlos

Staff
25,627 Points
2015-03-27 4:30 pm
Hello Carlos,

Have you added your IP to allow remote connection to MySQL in the cPanel?

Kindest Regards,
Scott M

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

18 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!