“Database error connection failed” in RoundCube cPanel – Causes and Fixes
RoundCube Webmail is an easy way to access emails when you are away from home network.
It is a feature rich application and stores all the data in database.
That’s why, in cPanel server, when RoundCube cannot connect to the database, it shows the message “database error connection failed“.
At Bobcares, we help customers to solve such RoundCube database errors as part of our Outsourced Technical Support Services for Web Hosts.
Today, let’s see the top causes for this error and how we fix them.
What causes “database error connection failed”?
RoundCube can use different database types like “MySQL” or “SQLite“. It stores all the details of email users, contacts, address books, etc. in this database.
So, the proper working of RoundCube webmail depends on the connection to this database. And, if the application is not able to connect to the database, it results in an error.
The typical RoundCube error message shown in cPanel servers with MySQL database is
DATABASE ERROR: CONNECTION FAILED! Unable to connect to the database! Please contact your server-administrator.
This error mainly happens due to :
1. Database server not running
When the MySQL server is not running, the RoundCube database will be down. And, the webmail will not be able to connect to the database. Thus, it shows the database connection error.
2. Corrupted RoundCube database
Similarly, even if the MySQL server is running, often there can be missing or buggy tables in RoundCube database. Additionally, in cPanel server, the details of all websites are stored in a single RoundCube database. This makes the database very big. These again can cause database connection problems.
How to fix RoundCube “database error connection failed” in cPanel ?
For the proper working of RoundCube, the database should be available all the time. Let’s see how our Dedicated Support Engineers fix the problem.
1. Fix MySQL connection
Here, to ensure that MySQL server is running, we first check with the command:
And to fix, we just restart the MySQL server to make it running again.
2. Restore/Repair database
Here, we first check if the RoundCube database is accessible from the command-line. Then, we check and validate the tables in it.
On seeing problems, we repair the tables first. If a table repair do not fix the connection, our Support Engineers restore the entire database from backup.
The exact command would be:
mysql roundcube < roundcube.sql
Here, roundcube.sql is the backup file of the database.
As a fail safe method, we take proper backup before removing the existing database.
3. Covert to SQLite database.
Now that we know this error happens only when RoundCube uses MySQL database, switching to SQLite really helps.
As of cPanel 11.4x, Roundcube only supports SQLite.
Also, there are many benefits for running Roundcube over SQLite including:
- Faster than MySQL
- Per account RoundCube database
- Easy restore and tracking of per user RoundCube database.
Fortunately, cPanel provides ready-made scripts to convert RoundCube to SQLite. So for server-wide conversion, our Hosting Support Engineers run the command
And to convert specific users, we run:
Again, we take a complete backup of the RoundCube database prior to the switch.
“Database error – connection failed” message appears in RoundCube mainly due to database connectivity issues. Today, we’ve seen the top reasons for the error and how our Support Engineers fix them.