{"id":20434,"date":"2026-11-02T12:30:06","date_gmt":"2026-11-02T11:30:06","guid":{"rendered":"https:\/\/stage.surver.nl\/kennisbank\/fout-databaseverbinding-wordpress\/"},"modified":"2026-11-03T12:14:30","modified_gmt":"2026-11-03T11:14:30","slug":"wordpress-database-connection-error","status":"publish","type":"kennisbank","link":"https:\/\/stage.surver.nl\/en\/kennisbank\/fout-databaseverbinding-wordpress\/","title":{"rendered":"\u2018Troubleshooting \u2019An error occurred while establishing a database connection\" (error establishing a database connection)"},"content":{"rendered":"<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"642\" src=\"https:\/\/stage.surver.nl\/wp-content\/uploads\/2026\/11\/kennisbank-fout-databaseverbinding-wordpress-v2.jpg\" alt=\"&#039;Troubleshooting &#039;An error occurred while establishing a database connection&quot; (error establishing a database connection)\" class=\"wp-image-20479\" srcset=\"https:\/\/stage.surver.nl\/wp-content\/uploads\/2026\/11\/kennisbank-fout-databaseverbinding-wordpress-v2.jpg 1024w, https:\/\/stage.surver.nl\/wp-content\/uploads\/2026\/11\/kennisbank-fout-databaseverbinding-wordpress-v2-300x188.jpg 300w, https:\/\/stage.surver.nl\/wp-content\/uploads\/2026\/11\/kennisbank-fout-databaseverbinding-wordpress-v2-768x482.jpg 768w, https:\/\/stage.surver.nl\/wp-content\/uploads\/2026\/11\/kennisbank-fout-databaseverbinding-wordpress-v2-18x12.jpg 18w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You open your site and see only one line of text: \u201cAn error occurred while establishing a database connection\u201d (in English, \u201cError establishing a database connection\u201d). Also <code>wp-admin<\/code> It's not working anymore. The database connection error means that WordPress cannot access the MySQL database. Check the database information in <code>wp-config.php<\/code>, whether the database server is running and whether the database is corrupted; repair it using <code>WP_ALLOW_REPAIR<\/code> or restore a backup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Don't panic. Your pages and orders are almost always still in the database; it's just that access to them is blocked.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wat-betekent-error-establishing-a-database-connection\">What does \u2018error establishing a database connection\u2019 mean?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\"Error establishing a database connection\" means that WordPress cannot connect to the MySQL or MariaDB database that contains all your content and settings. I often compare it to a filing cabinet. Everything from your site is in there, but WordPress has the wrong key, or the cabinet is in a room that\u2019s locked. More background in <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/hoe-werkt-wordpress-technisch\/\">How WordPress, PHP, and the database work together<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do you see what I mean? <code>wp-admin<\/code> \u201cOne or more database tables are unavailable\u201d\u2014in this case, the connection works, but the tables are corrupted. And \u201cCannot select database\u201d means that the login credentials are correct, but the database itself is missing, has a different name, or the user does not have permissions to access it.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>What you're seeing or have just done<\/th><th>Probable cause<\/th><th>Start at<\/th><\/tr><\/thead><tbody><tr><td>Just moved or changed your database password<\/td><td>Data in <code>wp-config.php<\/code> are incorrect<\/td><td>Step 1<\/td><\/tr><tr><td>\u201cCannot select database\u201d error message\u201d<\/td><td>Database deleted, renamed, or without permissions<\/td><td>Step 1<\/td><\/tr><tr><td>phpMyAdmin and other sites on your account aren't working either<\/td><td>Database server down or overloaded<\/td><td>Step 2<\/td><\/tr><tr><td>Errors come and go when things get busy<\/td><td>Connection limit or insufficient server resources<\/td><td>Step 2<\/td><\/tr><tr><td>Report in <code>wp-admin<\/code> About Unavailable Tables<\/td><td>Damaged tables<\/td><td>Step 3<\/td><\/tr><tr><td><code>wp-config.php<\/code> has been modified even though no one changed anything, or there are unknown files<\/td><td>Possible hack<\/td><td>Scan for malware and read <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/wordpress-website-hacked-what-now\/\">WordPress website hacked, now what?<\/a> or have the repair done through <a href=\"https:\/\/stage.surver.nl\/en\/services\/wordpress-hacked\/\">WordPress hacked<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In most of the cases I see, it involves the first row. Be sure to download a copy of <code>wp-config.php<\/code> and check to see if there's a recent backup, because a single typo in that file will immediately cause a new error. If you suspect a hack, it helps that Imunify scans every file change on Surver's shared hosting plans.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"stap-1-controleer-de-databasegegevens-in-wp-config-php\">Step 1: Check the database information in wp-config.php<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The database data in <code>wp-config.php<\/code> must match exactly the database and database user in your hosting control panel, and that's exactly where things usually go wrong.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <code>wp-config.php<\/code> in your site's root directory via File Manager in cPanel or via (S)FTP.<\/li>\n\n<li>Find the four lines <code>define( 'DB_NAME', 'database_name' );<\/code>, <code>define( 'DB_USER', 'database_user' );<\/code>, <code>define( 'DB_PASSWORD', 'password' );<\/code> and <code>define( 'DB_HOST', 'localhost' );<\/code>.<\/li>\n\n<li>Compare them in cPanel under <strong>MySQL databases<\/strong> with the name of the database and the database user.<\/li>\n\n<li>If you're unsure about the password, set a new password for the database user in your hosting control panel and enter exactly the same one <code>DB_PASSWORD<\/code>.<\/li>\n\n<li>Check in the same location to see if the user is associated with the database with full permissions.<\/li>\n\n<li>Save the file and refresh your site.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">When editing, pay attention to the small details. Use straight single quotation marks, not the curly quotes found in Word or emails, and do not include spaces inside the quotation marks. <code>DB_HOST<\/code> is usually <code>localhost<\/code>, but some hosting providers use a different server name or port, so check with them if you're unsure. If you get the error right after a migration, the file often still contains data from the old host. The complete step-by-step guide is available at <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/step-by-step-guide-to-moving-a-wordpress-website\/\">Moving a WordPress Website<\/a>, and if you don't want to do it yourself, our <a href=\"https:\/\/stage.surver.nl\/en\/managed-hosting\/moving-service-website\/\">moving service<\/a> as well as the database data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"stap-2-controleer-of-de-databaseserver-draait\">Step 2: Check whether the database server is running<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you can't log in to phpMyAdmin in cPanel, the problem isn't with WordPress but with the database server. Also check whether other sites on your account are working and whether your host has reported an outage. At Surver, you can check this at status.surver.nl. Usually, the issue is caused by overload due to too many simultaneous connections (the \u201ctoo many connections\u201d message), a full disk, or a server restart. If a high-traffic site frequently encounters this problem, then <a href=\"https:\/\/stage.surver.nl\/en\/managed-hosting\/cloud\/\">managed cloud hosting<\/a> worth considering.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I want to be honest here. If the database server is down, there\u2019s not much you can do on your own. That\u2019s your hosting provider\u2019s job, and they\u2019re the ones who should report it. Contact them and mention the time it happened and what you\u2019ve already checked. I\u2019d rather not put a PHP test script with your database password\u2014as some guides recommend\u2014on the server, because such a file often gets left behind. If you want to take a broader look at why your site is down, read <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/reasons-why-a-wordpress-website-goes-offline\/\">WordPress Website Offline<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"stap-3-repareer-beschadigde-databasetabellen\">Step 3: Repair Damaged Database Tables<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can repair damaged tables using phpMyAdmin, WP-CLI, or WordPress\u2019s built-in repair page, in that order of preference. Tables can become damaged or corrupted after a server crash, a full disk, or an update that fails partway through.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The easiest way is to use phpMyAdmin. Choose your database, select all tables, and at the bottom, click <strong>Repair Table<\/strong>. If you prefer to work from the command line, you can do so via SSH using WP-CLI, which is available on all Surver shared hosting plans. With <code>wp db check<\/code> you can see which tables are incorrect, and <code>WP DB Repair<\/code> She fixes them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If neither of those works, WordPress has its own troubleshooting page. Enter the line <code>define( 'WP_ALLOW_REPAIR', true );<\/code> in <code>wp-config.php<\/code>, above the line <code>\/* That's all, stop editing! *\/<\/code>. Then go to <code>jouwdomein.nl\/wp-admin\/maint\/repair.php<\/code> and select <strong>Repair Database<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Delete that line immediately after the repair. As long as <code>WP_ALLOW_REPAIR<\/code> If it's enabled, anyone can open that page without logging in. That's why I only use this method when phpMyAdmin and WP-CLI aren't available.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"stap-4-zet-een-back-up-terug-als-niets-helpt\">Step 4: Restore a backup if nothing else works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If none of the above works, first replace the core files and only then restore a backup. Upload the new folders <code>wp-admin<\/code> and <code>wp-includes<\/code> from wordpress.org and let <code>wp-content<\/code> and <code>wp-config.php<\/code> If that doesn't help, restore the database to a state prior to the problem. On Surver's shared hosting plans, you can do this yourself at no cost using JetBackup 5 in cPanel, where you can choose to restore just the database or just the files. Be sure to back up the current state beforehand, as it won\u2019t be automatically preserved during the restore. See <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/restoring-a-wordpress-backup\/\">Restore a backup<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With a WooCommerce online store, everything that happened after the backup was taken will be lost\u2014including orders, customer accounts, and inventory changes. Make a note of the orders from your payment provider and the WooCommerce emails beforehand. That\u2019s why troubleshooting always takes priority over restoring a backup, because restoring a backup to a live online store will cause you to lose today\u2019s orders. More on this in <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/woocommerce-backup\/\">WooCommerce Backup<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At Surver, we monitor the servers, including the database server. If the error is on your site itself, then on our <a href=\"https:\/\/stage.surver.nl\/en\/managed-hosting\/wordpress\/\">Managed WordPress Hosting<\/a> Everything at your fingertips, from phpMyAdmin and File Manager in cPanel to SSH and WP-CLI. To avoid repetition, only change the database password in conjunction with <code>wp-config.php<\/code> and after moving, test your connection before changing the DNS settings. With <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/uptime-monitoring-wordpress\/\">uptime monitoring<\/a> you'll know before your customers do, and within <a href=\"https:\/\/stage.surver.nl\/en\/services\/wordpress-maintenance-management\/\">WordPress Management<\/a> Surver checks every minute to see if your site is accessible. If you receive a different notification, please check the <a href=\"https:\/\/stage.surver.nl\/en\/knowledge-base\/troubleshooting-wordpress-errors\/\">Overview of WordPress Error Messages<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"veelgestelde-vragen\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Will my content be lost if this error occurs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Usually not. The error is related to the connection to the database, not the data itself, so your pages, posts, and orders are still there. You'll only need a backup in the event of serious damage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why am I getting this error after moving?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, the database name, username, password, or host are correct <code>wp-config.php<\/code> not with the new hosting. Sometimes the database hasn't been imported yet, or the user hasn't been added to it yet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can Surver fix this for me?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the issue is with the database server, that\u2019s Surver\u2019s responsibility, and you can check for outages at status.surver.nl. If the cause is on your site, you can restore the database yourself using JetBackup 5 or ask support to take a look. We do not promise a recovery time in advance.<\/p>","protected":false},"excerpt":{"rendered":"<p>Je opent je site en ziet alleen nog \u00e9\u00e9n regel tekst, &#8220;Er is een fout bij het maken van een databaseverbinding&#8221; (in het Engels &#8220;Error establishing a database connection&#8221;). Ook wp-admin doet het niet meer. De databaseverbindingsfout betekent dat WordPress de MySQL-database niet kan bereiken. Controleer de databasegegevens in wp-config.php, of de databaseserver draait en [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":20479,"template":"","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"kennisbank_categorieen":[62],"class_list":["post-20434","kennisbank","type-kennisbank","status-publish","has-post-thumbnail","hentry","kennisbank_categorieen-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/kennisbank\/20434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/kennisbank"}],"about":[{"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/types\/kennisbank"}],"author":[{"embeddable":true,"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/media\/20479"}],"wp:attachment":[{"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/media?parent=20434"}],"wp:term":[{"taxonomy":"kennisbank_categorieen","embeddable":true,"href":"https:\/\/stage.surver.nl\/en\/wp-json\/wp\/v2\/kennisbank_categorieen?post=20434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}