![]() |
|
Guide Fix "Error Establishing a Database Connection" in WordPress on CyberPanel - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel WordPress & LSCache Guides (https://adminsforum.com/Forum-cyberpanel-wordpress-lscache-guides) +----- Thread: Guide Fix "Error Establishing a Database Connection" in WordPress on CyberPanel (/Thread-guide-fix-error-establishing-a-database-connection-in-wordpress-on-cyberpanel) |
Fix "Error Establishing a Database Connection" in WordPress on CyberPanel - JAY - 10-27-2026 Fix "Error Establishing a Database Connection" in WordPress on CyberPanel The page is white with one sentence: Error establishing a database connection. WordPress shows the same message for half a dozen different problems, so guessing wastes time. We broke a test WordPress site on CyberPanel (3.0, OpenLiteSpeed, MariaDB 10.11) on purpose, in every common way, and noted the exact error behind each one. With one command you can see which one you have. Step 1: Get the real error Log in with SSH and go to the site's folder (the one with Code: wp-config.phpCode: grep extUser /usr/local/lsws/conf/vhosts/DOMAIN/vhost.confCode: cd /home/example.com/public_html
sudo -u SITEUSER -H wp db query "SELECT 1" --skip-plugins --skip-themesWordPress hides the reason, WP-CLI tells you: Here: Code: ERROR 1045 ... Access denied for user 'moved_wp'@'localhost' (using password: YES)Code: sudo -u SITEUSER -H wp config get DB_NAME
sudo -u SITEUSER -H wp config get DB_USER
sudo -u SITEUSER -H wp config get DB_HOSTWatch out, the homepage can look fine. With LiteSpeed Cache, the homepage still loaded from the cache ( Code: x-litespeed-cache: hitCode: wp-login.phpCode: /wp-login.phpHomepage fine, login page broken: ERROR 1045: Access denied ... (using password: YES) The password in Code: wp-config.phpCode: wp-config.phpCode: wp-config.phpCode: sudo -u SITEUSER -H wp config set DB_PASSWORD 'THE-PASSWORD' --quietCode: 1ERROR 2002: Can't connect to local server through socket MariaDB isn't running, so every site on the server that uses a database is down at once. We stopped MariaDB for this test: Password fixed, then MariaDB stopped: Code: systemctl start mariadb
systemctl status mariadbCode: journalctl -u mariadb -n 50
dmesg -T | grep -iE 'out of memory|killed process'Code: innodb_buffer_pool_sizeCode: df -hERROR 1044: Access denied for user ... to database '...' The user and password are right, but Code: DB_NAMECode: sudo -u SITEUSER -H wp config set DB_NAME the_real_nameERROR 2005: Unknown server host '...' Code: DB_HOSTCode: mysql.example.comCode: sudo -u SITEUSER -H wp config set DB_HOST localhostWrong database name, then a wrong host: Code: localhostCode: localhost:3306Code: localhostCode: 127.0.0.1Still broken?
Quick reference
More CyberPanel guides
|