{"id":583,"date":"2016-06-01T00:00:00","date_gmt":"2016-06-01T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/wordpresswordpress-error-establishing-database-connection\/"},"modified":"2025-12-22T14:47:54","modified_gmt":"2025-12-22T14:47:54","slug":"how-to-fix-error-establishing-a-database-connection-in-wordpress","status":"publish","type":"post","link":"\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","title":{"rendered":"How to fix &#8220;Error establishing a database connection&#8221; in WordPress"},"content":{"rendered":"<p>&ldquo;Error establishing a database connection&rdquo; in WordPress means <strong>your website cannot communicate with its MySQL database<\/strong>, preventing the site from loading and showing an error message instead.<\/p><p>This problem usually comes from incorrect database credentials in the configuration file, a corrupted database, or an unresponsive server. To fix it, check your credentials, repair the database, and make sure your server is running correctly.<\/p><ol class=\"wp-block-list\">\n<li>Check your database credentials.<\/li>\n\n\n\n<li>Verify the database server status.<\/li>\n\n\n\n<li>Repair the WordPress database.<\/li>\n\n\n\n<li>Replace corrupted core files.<\/li>\n\n\n\n<li>Create a new database and restore it from a backup.<\/li>\n\n\n\n<li>Update the WordPress website URL.<\/li>\n\n\n\n<li>Confirm that your domain points to the correct host.<\/li>\n\n\n\n<li>Contact your hosting provider or reboot the server.<\/li>\n<\/ol><p>If you prefer a visual guide to solve &ldquo;Error establishing a database connection,&rdquo; check out this video from Hostinger Academy. It covers how to match your database login credentials, verify where your domain is pointing, and fix corrupted files.<\/p><figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"How to Fix Error Establishing a Database Connection\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/WsdND0nun6s?start=1&amp;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure><p>\n\n\n\n  <div class=\"youtube-shortcode\">\n    <div class=\"row\">\n      <div class=\"col-7 col-sm-8 d-flex align-items-center\">\n        <img decoding=\"async\" class=\"channel-logo\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/youtube-channels\/hostinger-academy.jpg\" alt=\"youtube channel logo\">\n        <div class=\"d-flex flex-column justify-content-between\">\n          <span class=\"slogan d-none d-sm-block\">Subscribe For more educational videos!<\/span>\n          <span class=\"channel-name\">Hostinger Academy<\/span>\n                    <\/div>\n      <\/div>\n      <div class=\"col-5 col-sm-4 d-flex align-items-center justify-content-end\">\n          <a class=\"subscribe-button\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"http:\/\/www.youtube.com\/channel\/UCbNIC-svDbtUOH2qsLnPQPg?sub_confirmation=1\">\n            <img decoding=\"async\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/icons\/youtube.svg\" alt=\"subscribe\">\n            <span>Subscribe<\/span>\n          <\/a>\n      <\/div>\n    <\/div>\n  <\/div>\n\n    \n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-error-establishing-a-database-connection\">What is &ldquo;Error establishing a database connection&rdquo;?<\/h2><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675be234\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675be234\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"407\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\/public\" alt=\"Screenshot of a WordPress &ldquo;Error establishing a database connection&rdquo; message with a list of potential causes displayed below.\" class=\"wp-image-104811\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/error-establishing-database-connection-with-potential-causes.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><p>&ldquo;Error establishing a database connection&rdquo; is a common WordPress issue that occurs <strong>when your website&rsquo;s files (PHP) fail to communicate with its MySQL database.<\/strong><\/p><p>Your WordPress site runs on the <a href=\"\/tutorials\/what-is-php\">PHP programming language<\/a>, while all of its content and settings live in a <a href=\"\/tutorials\/what-is-mysql\">MySQL database<\/a>.<\/p><p>When a visitor opens your website, PHP code runs a request to fetch the necessary information from the database. The database then returns the data, and WordPress assembles it into a complete web page.<\/p><p>If the PHP code cannot connect to the database, the process stops, and the error message appears.<\/p><p>Sometimes, you may not see this error immediately on the front end if your site serves a cached version of a page.<\/p><p>A clear sign of the problem is when you can&rsquo;t access your WordPress admin dashboard, since the backend almost always requires a live database connection.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-causes-error-establishing-a-database-connection-in-wordpress\">What causes &ldquo;Error establishing a database connection&rdquo; in WordPress?<\/h2><p>Several issues &ndash; such as <strong>incorrect database credentials, a corrupted database, or an overloaded server<\/strong> &ndash; can disrupt the connection between WordPress and its database.<\/p><ul class=\"wp-block-list\">\n<li><strong>Incorrect database credentials<\/strong> is the most common cause. The <strong>wp-config.php<\/strong> file stores the database name, username, password, and host. If any of these details are wrong, WordPress cannot log in to the database.<\/li>\n\n\n\n<li><strong>A corrupted database<\/strong> can also block the connection. <a href=\"\/tutorials\/wordpress-database\">WordPress database<\/a> tables may become corrupted after a faulty plugin or theme update, or because of an unexpected server shutdown.<\/li>\n\n\n\n<li><strong>An overloaded or unresponsive MySQL server<\/strong> may fail to handle connection requests. This usually happens when your hosting server experiences a traffic spike that exceeds its resources or when the database server itself goes down.<\/li>\n\n\n\n<li><strong>Corrupted WordPress core files<\/strong> can disrupt your site&rsquo;s operation. If essential files are damaged or modified incorrectly, WordPress may fail to initiate a database connection.<\/li>\n\n\n\n<li><strong>A misconfigured website URL<\/strong> after a site migration often breaks the database link. If you move your site to a new host or domain, outdated URL values in the database can cause redirect loops or connection failures.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-fix-the-wordpress-error-establishing-a-database-connection\">How to fix the WordPress &ldquo;Error establishing a database connection&rdquo;<\/h2><p>To fix &ldquo;Error establishing a database connection&rdquo; in WordPress, start by <strong>verifying your database credentials in the wp-config.php file and checking if the database is online and accessible.<\/strong><\/p><p>If the problem persists, repair the WordPress database or replace any corrupted core files. If that doesn&rsquo;t work, create a new database, update your site&rsquo;s URL, and confirm that your domain points to the correct host.<\/p><p>If none of these steps solve the issue, reboot your server yourself or contact your hosting provider for assistance.<\/p><p>Before trying any of these solutions, we strongly recommend <a href=\"\/tutorials\/backup-wordpress\">creating a backup of your WordPress site<\/a>. This way, you can restore your site if something goes wrong during troubleshooting.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-check-your-database-credentials\">1. Check your database credentials<\/h3><p>The most common cause of a database connection error is incorrect credentials in your <a href=\"\/tutorials\/how-to-use-wp-config-php-wordpress-function\">wp-config.php<\/a> file. This often happens after migrating your site to a new host.<\/p><p>First, locate your correct database credentials in your hosting control panel. Then, compare them with the values in your <strong>wp-config.php<\/strong> file.<\/p><p>For <a href=\"\/wordpress-hosting\">Hostinger&rsquo;s managed WordPress<\/a> customers, here&rsquo;s how to do it in hPanel:<\/p><ol class=\"wp-block-list\">\n<li>Log in to hPanel using your Hostinger account, then navigate to <strong>Websites &rarr; Website list &rarr; Dashboard<\/strong>.<\/li>\n\n\n\n<li>From the dashboard&rsquo;s left sidebar, go to <strong>Databases &rarr; Management<\/strong>.<\/li>\n\n\n\n<li>Under the <strong>List of Current MySQL Databases and Users<\/strong> section, note your MySQL database name and user.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675bf377\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675bf377\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2158\" height=\"814\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/public\" alt=\"Screenshot of Hostinger hPanel showing the management page with the list of current MySQL databases and users.\" class=\"wp-image-134835\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=2158,fit=scale-down 2158w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-management-list-of-current-mysql-databases-and-users.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2158px) 100vw, 2158px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>If you don&rsquo;t know the password, create a new one by clicking the <strong>three-dot icon<\/strong> next to the user and selecting <strong>Change Password<\/strong>.<\/li>\n\n\n\n<li>Next, navigate to <strong>Files &rarr; File Manager<\/strong> and open your site&rsquo;s root directory, typically <strong>public_html<\/strong>.<\/li>\n\n\n\n<li>Right-click on the <strong>wp-config.php<\/strong> file and select <strong>Edit<\/strong>.<\/li>\n\n\n\n<li>Compare the following values with the ones in your database management panel:\n<ul class=\"wp-block-list\">\n<li><strong>DB_NAME<\/strong> &ndash; your MySQL database name.<\/li>\n\n\n\n<li><strong>DB_USER<\/strong> &ndash; your MySQL database username.<\/li>\n\n\n\n<li><strong>DB_PASSWORD<\/strong> &ndash; your MySQL database password.<\/li>\n\n\n\n<li><strong>DB_HOST<\/strong> &ndash; your MySQL database host (usually localhost or <strong>127.0.0.1<\/strong>, but confirm with your provider).<\/li>\n<\/ul>\n<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c00fa\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c00fa\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2560\" height=\"1086\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/public\" alt=\"Screenshot of Hostinger hPanel File Manager with the wp-config.php database settings highlighted.\" class=\"wp-image-134836\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=2560,fit=scale-down 2560w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-file-manager-wp-config-php-database-settings-highlighted-scaled.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"8\" class=\"wp-block-list\">\n<li>If any values are incorrect, update them directly in the file and click the <strong>Save<\/strong> icon. Then refresh your website to check if the error is fixed.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-wordpress-hosting\" href=\"\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"2048\" height=\"600\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/public\" alt=\"\" class=\"wp-image-111781\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-2-check-the-database-server-status\">2. Check the database server status<\/h3><p>If your credentials are correct, the problem stems from the MySQL database server itself. The server could be down or unable to process requests because of a traffic surge.<\/p><p>To confirm this, contact your hosting provider&rsquo;s support team. Ask if other users on the same server are having issues or if the MySQL server is offline.<\/p><p>If you host another site on the same server, run a quick test to see if those sites are working. If they&rsquo;re also down, it&rsquo;s a strong sign that the issue is on your hosting provider&rsquo;s side.<\/p><p>At Hostinger, you can check the <a href=\"https:\/\/statuspage.hostinger.com\" target=\"_blank\" rel=\"noopener\">status page<\/a> for any ongoing server maintenance or reported issues.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-repair-the-wordpress-database\">3. Repair the WordPress database<\/h3><p>If your database tables are corrupted, WordPress can&rsquo;t retrieve data from them. Fortunately, WordPress includes a built-in database repair mode that you can activate.<\/p><p>Follow these steps to repair your database:<\/p><ol class=\"wp-block-list\">\n<li>Open your <strong>wp-config.php<\/strong> file using the <strong>File Manager<\/strong>.<\/li>\n\n\n\n<li>Add the following line of code at the bottom of the file:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">define('WP_ALLOW_REPAIR', true);<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Save the changes.<\/li>\n\n\n\n<li>In your browser, go to <strong>http:\/\/your-site-domain.com\/wp-admin\/maint\/repair.php<\/strong>, replacing <strong>your-site-domain.com<\/strong> with your actual website URL.<\/li>\n\n\n\n<li>On that page, you&rsquo;ll see two options. Click <strong>Repair Database<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c1b36\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c1b36\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1974\" height=\"1046\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/public\" alt=\"Screenshot of the WordPress admin repair database page with the Repair Database button highlighted.\" class=\"wp-image-134839\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=1974,fit=scale-down 1974w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/wordpress-admin-repair-database-highlighted.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1974px) 100vw, 1974px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><p>Once the process finishes, revisit your website. If it loads correctly, remove the line <strong>define(&lsquo;WP_ALLOW_REPAIR&rsquo;, true); <\/strong>from your <strong>wp-config.php<\/strong> file immediately. Leaving it enabled is a security risk because anyone could access that repair page.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-replace-corrupted-core-files\">4. Replace corrupted core files<\/h3><p>Corrupted WordPress core files can also interfere with the database connection. This often happens during a manual update or due to a file transfer error. You can fix it by replacing your core files with a fresh copy.<\/p><p>Here are the instructions:<\/p><ol class=\"wp-block-list\">\n<li>Go to the official <a href=\"https:\/\/wordpress.org\/download\" target=\"_blank\" rel=\"noopener\">WordPress.org website<\/a> and download the latest version.<\/li>\n\n\n\n<li>Extract the ZIP file on your computer.<\/li>\n\n\n\n<li>Inside the extracted folder, delete the <strong>wp-content<\/strong> folder and the <strong>wp-config-sample.php<\/strong> file.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c25f2\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c25f2\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"972\" height=\"772\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/macos-finder-wordpress.png\/public\" alt=\"Screenshot of macOS Finder window displaying extracted WordPress installation files.\" class=\"wp-image-134844\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/macos-finder-wordpress.png\/w=972,fit=scale-down 972w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/macos-finder-wordpress.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/macos-finder-wordpress.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/macos-finder-wordpress.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 972px) 100vw, 972px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Connect to your website using an <a href=\"\/tutorials\/ftp\/filezilla-ftp-configuration\">FTP client like FileZilla<\/a> or your host&rsquo;s <strong>File Manager<\/strong>.<\/li>\n\n\n\n<li>Upload the remaining files and folders to your website&rsquo;s root directory, overwriting the existing ones.<\/li>\n<\/ol><p>This process replaces all the core files without touching your content, themes, or plugins. After the upload is complete, check your website again.<\/p><h3 class=\"wp-block-heading\" id=\"h-5-create-a-new-database-and-restore-from-backup\">5. Create a new database and restore from backup<\/h3><p>If your database is severely corrupted and can&rsquo;t be repaired, the best solution is to <a href=\"https:\/\/www.hostinger.com\/support\/4283700-how-to-restore-backups-at-hostinger\">restore it from a backup<\/a>. This process involves creating a new, empty database and importing your backup file into it.<\/p><p>Here&rsquo;s how to do it with Hostinger:<\/p><ol class=\"wp-block-list\">\n<li>In hPanel, go to <strong>Files &rarr; Backups &rarr; Restore and download<\/strong>.<\/li>\n\n\n\n<li>Select <strong>Database backups<\/strong>, choose the latest clean backup, and click <strong>Download database<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c3067\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c3067\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2164\" height=\"746\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/public\" alt=\"Screenshot of Hostinger hPanel showing the Files &rarr; Backups section with the Download database option highlighted.\" class=\"wp-image-134857\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=2164,fit=scale-down 2164w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-files-backups-download-database-highlighted.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2164px) 100vw, 2164px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Navigate to <strong>Databases &rarr; Management<\/strong>, enter a new database name, username, and password, then click <strong>Create<\/strong>.<\/li>\n\n\n\n<li>Scroll down to your new database and click <strong>Enter phpMyAdmin<\/strong>.<\/li>\n\n\n\n<li>Select the <strong>Import<\/strong> tab, choose your downloaded backup file, and hit <strong>Import<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c3a0d\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c3a0d\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2308\" height=\"1554\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/public\" alt=\"Screenshot of phpMyAdmin&rsquo;s Import tab with a backup file selected for upload.\" class=\"wp-image-134858\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=2308,fit=scale-down 2308w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-import-selected.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2308px) 100vw, 2308px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>Open your <strong>wp-config.php<\/strong> file and update the <strong>DB_NAME<\/strong>, <strong>DB_USER<\/strong>, and <strong>DB_PASSWORD<\/strong> values to match the new database you created.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-6-update-the-wordpress-website-url\">6. Update the WordPress website URL<\/h3><p>If the error appears right after <a href=\"\/tutorials\/how-to-migrate-wordpress\">migrating your WordPress site<\/a> to a new server or domain, it indicates a misconfigured site URL in the database. You can fix this by <a href=\"\/tutorials\/wordpress\/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin\">updating the WordPress site URL in phpMyAdmin<\/a>.<\/p><p>\n\n\n    <p class=\"warning\">\n        <strong>Warning!<\/strong> Running SQL queries directly can be risky if you&rsquo;re not careful. Always back up your database before making changes in phpMyAdmin.    <\/p>\n    \n\n\n\n<\/p><p>Follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Open <strong>phpMyAdmin<\/strong> from your hosting control panel.<\/li>\n\n\n\n<li>Select your WordPress database from the list on the left.<\/li>\n\n\n\n<li>Click the <strong>SQL<\/strong> tab.<\/li>\n\n\n\n<li>Enter the following queries, replacing <strong>http:\/\/www.old-domain.com<\/strong> with your old URL and <strong>http:\/\/www.new-domain.com<\/strong> with your new one:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">UPDATE wp_options SET option_value = replace(option_value, 'http:\/\/www.old-domain.com', 'http:\/\/www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';\nUPDATE wp_posts SET guid = replace(guid, 'http:\/\/www.old-domain.com','http:\/\/www.new-domain.com');\nUPDATE wp_posts SET post_content = replace(post_content, 'http:\/\/www.old-domain.com', 'http:\/\/www.new-domain.com');\nUPDATE wp_postmeta SET meta_value = replace(meta_value,'http:\/\/www.old-domain.com','http:\/\/www.new-domain.com');<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c457f\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c457f\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2400\" height=\"1088\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/public\" alt=\"Screenshot of phpMyAdmin with the SQL tab selected to run custom database queries.\" class=\"wp-image-134864\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=2400,fit=scale-down 2400w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/phpmyadmin-sql-selected.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2400px) 100vw, 2400px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>Click <strong>Go<\/strong> to execute the queries.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-7-make-sure-your-domain-points-to-the-right-host\">7. Make sure your domain points to the right host<\/h3><p>After a migration, it&rsquo;s crucial that your domain&rsquo;s DNS settings point to your new hosting provider. If your domain still points to the old host, WordPress will attempt to connect to the old database, which causes an error.<\/p><p>To check this, verify your domain&rsquo;s nameservers. If both your domain and website are hosted at Hostinger, the nameservers are set automatically. In this case, you don&rsquo;t need to change anything.<\/p><p>If you host your website with Hostinger but registered your domain elsewhere, you can find your nameservers under <strong>Websites &rarr; Website list &rarr; Dashboard &rarr; Hosting Plan &rarr; Plan details<\/strong>.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c4f10\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c4f10\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2560\" height=\"833\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/public\" alt=\"Screenshot of Hostinger hPanel Hosting Plan details page with the current nameservers highlighted.\" class=\"wp-image-134875\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=2560,fit=scale-down 2560w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-websites-hosting-plan-details-current-nameserver-1-2-highlighted-scaled.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><p>Next, use a tool like <a href=\"https:\/\/dnschecker.org\" target=\"_blank\" rel=\"noopener\">DNS Checker<\/a> to confirm where your domain is currently pointing. If the nameservers are incorrect, log in to your domain registrar&rsquo;s control panel and point them to Hostinger&rsquo;s nameservers.<\/p><p>If you <a href=\"\/domain-name-search\">registered your domain with Hostinger<\/a> but host your site with another provider, the process is similar but reversed. You&rsquo;ll need to get the correct nameservers from your hosting provider, then <a href=\"https:\/\/support.hostinger.com\/en\/articles\/1696789-how-to-change-nameservers-at-hostinger\" target=\"_blank\" rel=\"noopener\">update them in Hostinger<\/a>:<\/p><ol class=\"wp-block-list\">\n<li>Go to <strong>Domains &rarr; Domain portfolio &rarr; Manage<\/strong>.<\/li>\n\n\n\n<li>In the <strong>DNS \/ Nameserver<\/strong> section, open the <strong>DNS records<\/strong> tab.<\/li>\n\n\n\n<li>Click <strong>Change nameservers<\/strong> and enter the new nameservers provided by your host.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c5916\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c5916\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2098\" height=\"952\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/public\" alt=\"Screenshot of Hostinger hPanel Domain Portfolio DNS\/Nameservers section with the Change nameservers button highlighted.\" class=\"wp-image-134876\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=2098,fit=scale-down 2098w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-domain-portfolio-dns-nameservers-change-nameservers-highlighted.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2098px) 100vw, 2098px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><p>After changing nameservers, keep in mind that DNS updates can take up to <strong>24 hours<\/strong> to propagate worldwide.<\/p><h3 class=\"wp-block-heading\" id=\"h-8-contact-your-hosting-provider-or-reboot-the-server\">8. Contact your hosting provider or reboot the server<\/h3><p>If you&rsquo;ve tried all the previous steps and the error still persists, it&rsquo;s time to contact your hosting provider. Their support team has server-level access and the right tools to diagnose complex issues.<\/p><p>Hostinger&rsquo;s <a href=\"\/contacts\">Customer Success<\/a> team is available 24\/7 to help resolve these problems.<\/p><p>If you use a virtual private server (VPS), you also have the option to reboot it. A reboot can clear temporary glitches or stop processes that are consuming too many server resources and blocking the database from responding.<\/p><p>For <a href=\"\/vps-hosting\">Hostinger VPS<\/a> customers, the <strong>Reboot VPS<\/strong> button is available on your <strong>VPS Overview<\/strong> page.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"6a14d675c649e\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a14d675c649e\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2176\" height=\"858\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/public\" alt=\"Screenshot of Hostinger hPanel VPS Overview page with the Reboot VPS button highlighted.\" class=\"wp-image-134877\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=2176,fit=scale-down 2176w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/hpanel-vps-overview-reboot-vps-highlighted.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2176px) 100vw, 2176px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div><p>\n\n<div class=\"protip\">\n                    <h4 class=\"title\">&#128161; Pro tip<\/h4>\n                    <p>Always <a href=\"https:\/\/www.hostinger.com\/support\/1583232-how-to-back-up-or-restore-a-vps-at-hostinger\">back up your VPS<\/a> before rebooting it. This way, you can quickly restore your site if something unexpected happens during the restart.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-prevent-database-connection-errors-in-wordpress\">How to prevent database connection errors in WordPress<\/h2><p>Preventing database connection errors in WordPress involves <strong>enabling automated site backups, optimizing database tables, using trusted plugins and themes, choosing a reliable hosting provider, and monitoring your site&rsquo;s resource usage<\/strong>.<\/p><ul class=\"wp-block-list\">\n<li><strong>Enable automated backups<\/strong>. This lets you quickly restore your database if it becomes corrupted. Hostinger plans include automatic daily or weekly backups, so you always have a recent version of your site to fall back on.<\/li>\n\n\n\n<li><strong>Regularly optimize database tables<\/strong>. Over time, your database accumulates unnecessary data. Use a plugin like <strong>WP-Optimize<\/strong> to clean up your database, improve performance, and reduce the risk of corruption.<\/li>\n\n\n\n<li><strong>Use trusted plugins and themes<\/strong>. Only install plugins and themes from reputable sources like the official WordPress repository. Poorly coded software is a common cause of database conflicts and corruption.<\/li>\n\n\n\n<li><strong>Choose a reliable hosting provider<\/strong>. A quality web host like Hostinger provides an optimized server environment for MySQL, minimizing the risk of server-side errors and downtime.<\/li>\n\n\n\n<li><strong>Monitor database traffic and load<\/strong>. Keep an eye on your site&rsquo;s resource usage. If you consistently hit your server&rsquo;s limits, consider upgrading your hosting plan to prevent the database server from becoming overloaded.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-what-to-do-after-fixing-error-establishing-a-database-connection\">What to do after fixing &ldquo;Error establishing a database connection&rdquo;?<\/h2><p>After fixing &ldquo;Error establishing a database connection&rdquo; in WordPress, the next step is to <strong>keep your database running smoothly to avoid future problems<\/strong>.<\/p><p>A clean and optimized database not only reduces the risk of corruption but also improves your site&rsquo;s overall speed.<\/p><p>To maintain long-term site health, learn how to <a href=\"\/tutorials\/wordpress-database-optimization\">optimize your WordPress database<\/a> using the right tools and best practices. This will help your site stay stable and perform at its best as it grows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&ldquo;Error establishing a database connection&rdquo; in WordPress means your website cannot communicate with its MySQL database, preventing the site from [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":134831,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to fix \"Error establishing a database connection\" in WordPress","rank_math_description":"Can't connect to your WordPress database? Find 8 proven methods to fix \"Error establishing a database connection\" and get your site back online.","rank_math_focus_keyword":"error establishing a database connection","footnotes":""},"categories":[22640,22637],"tags":[],"class_list":["post-583","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security-and-maintenance","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-fix-error-establishing-a-database-connection-in-wordpress","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=583"}],"version-history":[{"count":110,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":138291,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/583\/revisions\/138291"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media\/134831"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}