“Could not connect to the database” error on CPanel

Recently we have setup new Linux server with WHM installed on it and we have enabled the cageFS on server which result in database connectivity issue.

“Could not connect to the database”

Clients having issue while connecting database using “localhost” as an hostname into their database configuration files. If you are also facing this kind of problem, so here is the solution:

We need to be very careful while configuring/enabling CageFS on the dedicated Linux as it can cause many errors if its not configured properly.
This is mostly happen due to the MySQL directory is not mounted in CageFS, The configuration file for the same is as below :

# /etc/cagefs/cagefs.mp

Please login to your server as a root and be careful while editing. You need to add the “/var/lib/mysql” under the file /etc/cagefs/cagefs.mp and remount the users:

# cagefsctl –remount-all

After doing this you will find all the websites with database will start working again .

We hope this article helped you to Fix “Could not connect to database error” on websites. Please check and give your opinion below if you experience any issues or to discuss your ideas and experiences.