{"id":775,"date":"2020-02-04T05:08:05","date_gmt":"2020-02-04T05:08:05","guid":{"rendered":"https:\/\/www.domainnamesanity.com\/blog\/?p=775"},"modified":"2020-04-06T06:32:56","modified_gmt":"2020-04-06T06:32:56","slug":"how-to-fix-error-establishing-a-database-connection-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/","title":{"rendered":"5 Fixes for Error Establishing a Database Connection in WordPress"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"775\" class=\"elementor elementor-775\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-230899b0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"230899b0\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7ff48571\" data-id=\"7ff48571\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-48deb20 elementor-widget elementor-widget-text-editor\" data-id=\"48deb20\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"breadcrumbs-bar\"><nav class=\"blog-breadcrumbs\">\n<ul>\n \t<li><a href=\"https:\/\/www.domainnamesanity.com\/\">HOME<\/a><\/li>\n \t<li class=\"bc-2nd\"><a href=\"https:\/\/www.domainnamesanity.com\/blog\/\">BLOG<\/a><\/li>\n<\/ul>\n<\/nav><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1c29e94 elementor-widget elementor-widget-theme-post-title elementor-page-title elementor-widget-heading\" data-id=\"1c29e94\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"theme-post-title.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">5 Fixes for Error Establishing a Database Connection in WordPress<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d6ac49d elementor-widget elementor-widget-post-info\" data-id=\"d6ac49d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-d9c2fd9 elementor-inline-item\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-custom\">\n\t\t\t\t\t\t\t\t\t\tBy Douglas Moore\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-6a0ea6c elementor-inline-item\" itemprop=\"datePublished\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-date\">\n\t\t\t\t\t\t\t<span class=\"elementor-post-info__item-prefix\">Last Updated On<\/span>\n\t\t\t\t\t\t\t\t\t\tFebruary 4, 2020\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8f51764 elementor-widget elementor-widget-theme-post-featured-image elementor-widget-image\" data-id=\"8f51764\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"theme-post-featured-image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"900\" height=\"675\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png\" class=\"attachment-full size-full wp-image-638\" alt=\"\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png 900w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress-300x225.png 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress-768x576.png 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-43ea192 toc-top elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"43ea192\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-inner-column elementor-element elementor-element-85705ab\" data-id=\"85705ab\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-29c4035 table-of-contents elementor-widget elementor-widget-heading\" data-id=\"29c4035\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">Table of Contents<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9f76f1c elementor-widget elementor-widget-text-editor\" data-id=\"9f76f1c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul class=\"table-of-contents-list\"><li><a href=\"#what-is-error-establishing-a-database-connection\">What is Error Establishing a Database Connection?<\/a><\/li><li><a href=\"#how-to-fix-the-error-establishing-a-database-connection-in-wordpress\">How to Fix the Error Establishing a Database Connection in WordPress<\/a><\/li><li class=\"sub-toc\"><a href=\"#check-if-the-error-code-is-the-same-in-wp-admin\">1. Check If the Error Code is the Same in \/wp-admin\/<\/a><\/li><li class=\"sub-toc\"><a href=\"#check-if-your-database-login-credentials-are-correct\">2. Check if Your Database Login Credentials are Correct<\/a><\/li><li class=\"sub-toc\"><a href=\"#fix-corrupt-files\">3. Fix Corrupt Files<\/a><\/li><li class=\"sub-toc\"><a href=\"#contact-your-web-hosting-provider\">4. Contact Your Web Hosting Provider<\/a><\/li><li class=\"sub-toc\"><a href=\"#restore-your-website-to-the-latest-backup\">5. Restore Your Website to the Latest Backup<\/a><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-197d5d2 elementor-widget elementor-widget-text-editor\" data-id=\"197d5d2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Nothing short of finding you\u2019ve run out of coffee in the morning can be as frustrating as finding \u201c<strong>Error establishing a database connection<\/strong>\u201d on your WordPres website. This error code indicates that your website has lost access to your WordPress database, and so it has gone down.<\/p><p><img decoding=\"async\" class=\"aligncenter size-full wp-image-777\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/Error-Establishing-Database-Connection.jpg\" alt=\"\" width=\"736\" height=\"167\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/Error-Establishing-Database-Connection.jpg 736w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/Error-Establishing-Database-Connection-300x68.jpg 300w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><\/p><p class=\"image-description\"><strong>Error establishing a database connection<\/strong><\/p><p>The worst part of your website going down is that it messes with your website\u2019s traffic. The longer your website is down, the more likely you are to drop lower in the SEO rankings, to miss out on potential customers, and lose site visitors.<\/p><p>So the main point here is that it\u2019s crucial to get your website up and running as soon as possible. As disconcerting as the error code is, don\u2019t worry! We\u2019ll go over the possible causes of the problems and what you can do to fix it in less than 20 minutes. Even if you\u2019re new to WordPress, our step-by-step guides will be easy for you to follow. You got this!<\/p><h2 id=\"what-is-error-establishing-a-database-connection\" class=\"c-anchor\">What is Error Establishing a Database Connection?<\/h2><p>As the name suggests, this error indicates that WordPress is unable to establish a connection to the database and retrieve important information so your website can properly present itself for your website visitors.<\/p><p>Whenever you get a website visitor, PHP runs the code of the page and fetches the necessary data from the database, so the website can be properly displayed in the visitor\u2019s browser. The MySQL database is where most of your WordPress website\u2019s information is stored &#8211; plugin and theme settings, post data, page data, meta data, login information, and so on. Media content, like images, and theme\/plugin\/core files are the only ones that aren\u2019t stored in the MySQL database.<\/p><p>However, if WordPress fails to establish a connection to the database, your visitors will get <strong>Error establishing a database connection<\/strong> instead of the website displayed in their browser. As PHP can\u2019t access the data, the page will be blank safe for that dreaded sentence.<\/p><p>Most of the time, this causes an issue both on the frontend of your website (the domain that is accessed by visitors) <em>and<\/em> on your wp-admin site, i.e. your WordPress dashboard (we\u2019ll go over how you can check this in a moment). Sometimes, the error won\u2019t immediately be visible from the frontend, as the site can load from the cache for a while. (This gives you a bit of leeway in not freaking out while you\u2019re getting the problem fixed.)<\/p><p>The <strong>error establishing a database connection <\/strong>problem can be caused by several reasons:<\/p><ul><li><strong><strong>Your database login credentials are wrong.<\/strong>\u00a0<\/strong><\/li><\/ul><p>WordPress uses a different set of login information in order to access its MySQL database. The error can occur if these login credentials are incorrect or have been changed.<\/p><ul><li><strong><strong>Your database server is unresponsive.<\/strong>\u00a0<\/strong><\/li><\/ul><p>Sometimes this issue can be caused by your web host. The server could be temporarily down or unresponsive due to too much traffic overloading the database. A lot of people use shared hosts which have limited, sometimes insufficient resources for a large number of users.<\/p><ul><li><strong><strong>Your database is corrupted.<\/strong>\u00a0<\/strong><\/li><\/ul><p>A database can get corrupted from the constantly changing plugins, themes, and user settings on your WordPress website. In the process of frequently installing and deleting plugins, you may not notice a missing or deleted file, which can corrupt the database. The same can happen due to an individually corrupted table.<\/p><ul><li><strong><strong>Corrupt files in your WordPress installation.<\/strong>\u00a0<\/strong><\/li><\/ul><p>This can be caused by a glitch during installation or by hackers.<\/p><p>Now that you know the most common causes of <strong>error establishing a database connection <\/strong>in WordPress, let\u2019s look at how we can troubleshoot and fix the problem together.<\/p><h2 id=\"how-to-fix-the-error-establishing-a-database-connection-in-wordpress\" class=\"c-anchor\">How to Fix the Error Establishing a Database Connection in WordPress<\/h2><p>Before we go into the various ways you can fix error establishing a database connection in WordPress, we strongly recommend that you <strong>backup your website, i.e. your files and database.<\/strong> As we tinker with various settings to get your website up and running again, there\u2019s always a chance that something may accidentally get done wrong. You don\u2019t want to lose any of your data!<\/p><p>You can use a WordPress backup plugin like <a href=\"https:\/\/wordpress.org\/plugins\/vaultpress\/\">VaultPress<\/a>, or you can manually backup the MySQL database via phpMyAdmin.<\/p><p>Without further ado, let\u2019s start troubleshooting and fixing!<\/p><h3 id=\"check-if-the-error-code-is-the-same-in-wp-admin\" class=\"c-anchor\">1. Check If the Error Code is the same in \/wp-admin\/<\/h3><p>The first and easiest thing you can do is check if the error appears the same on the frontend of the website (the domain that visitors visit) and the backend &#8211; your WordPress dashboard, i.e. wp-admin.<\/p><p><strong>If the message is the same<\/strong> (error establishing a database connection) on both of them, you can skip this step.<\/p><p><strong>If the message is slightly different on each,<\/strong> like it\u2019s \u201cError establishing a database connection\u201d on the frontend website but \u201cOne or more database tables are unavailable. The database may need to be repaired\u201d in your WordPress wp-admin, then you will need to repair the database.<\/p><p><strong>To do this:<\/strong><\/p><ol><li><strong> Open the wp-config.php file.<\/strong> Find the line that says:<\/li><\/ol><p>\u201cThat\u2019s all, stop editing! Happy blogging.\u201d<\/p><ol start=\"2\"><li><strong> Insert the following code<\/strong> just before that line:<\/li><\/ol><div class=\"pop-out\"><strong>define(&#8216;WP_ALLOW_REPAIR&#8217;, true);<\/strong><\/div><ol start=\"3\"><li><strong>Check the settings <\/strong>by accessing <strong>http:\/\/www.domain.com\/wp-admin\/maint\/repair.php<\/strong>, where <strong>domain<\/strong> is your website\u2019s name.<\/li><\/ol><ol start=\"4\"><li>The ensuing window will provide you with two options: <strong>Repair Database<\/strong> and <strong>Repair and Optimize Database.<\/strong> You can click on either, though we recommend the latter option for optimized performance.<\/li><\/ol><ol start=\"5\"><li>Once WordPress is done repairing and optimizing the database, which will take a couple of minutes, <strong>go back to the wp-config.php file.<\/strong><\/li><\/ol><ol start=\"6\"><li><strong> Delete the line we added earlier <\/strong>(i.e. define(&#8216;WP_ALLOW_REPAIR&#8217;, true);).<\/li><\/ol><ol start=\"7\"><li><strong> Try accessing your website.<\/strong> If you can now access your WordPress dashboard and website, you\u2019ve fixed the issue!<\/li><\/ol><p>If this didn\u2019t work, don\u2019t worry! Let\u2019s move onto the next possible solution.<\/p><h3 id=\"check-if-your-database-login-credentials-are-correct\" class=\"c-anchor\">2. Check if Your Database Login Credentials are Correct<\/h3><p>Incorrect database login details are one of the most common causes of the error establishing a database connection. So the best thing to do at this point if check if they are, in fact, correct. This can especially happen if you recently migrated to a new web host. If this is the case, there\u2019s a good chance that something went a bit awry in the transition.<\/p><h5><strong>Before we begin: if you don\u2019t have access to your MySQL server directly<\/strong>, <strong>you should immediately contact your web host<\/strong>.<\/h5><p>Oftentimes, the error establishing a database connection may be due to too much traffic on your website overwhelming the host &#8211; and this is especially the case if you\u2019re using a shared host. Simply get on <strong>livechat<\/strong> with your web hosting provider so that they can check for you if your MySQL server is responsive and working properly. If you have multiple websites on the same hosting provider, and the same error appears on all of them, this means that most likely there\u2019s an issue with the MySQL server and your host should get it sorted.<\/p><p>If you want to try sorting it out yourself &#8211; don\u2019t worry, it\u2019s easy! You just need to check if the values for the credentials are correct in each corresponding file.<\/p><p>To do this:<\/p><h4>Via FTP Client<\/h4><ol><li><strong> Connect to your site via SFTP<\/strong>. (If you\u2019re using cPanel, which we\u2019ll cover in a bit, go to <strong>File Manager <\/strong>and browse the settings in the <strong>root file.<\/strong>)<\/li><\/ol><p>(If you don\u2019t know how to connect via FTP yet: open your <strong>browser<\/strong> or <strong>file explorer<\/strong>, and type in <strong>ftp:\/\/[FTP-server-IP-or-domain-name]<\/strong>, where <strong>server IP or domain name<\/strong> are your server\u2019s IP or domain name, then press <strong>Enter<\/strong>. Write in your <strong>username<\/strong> and <strong>password<\/strong> and select <strong>Log On <\/strong>to connect to your FTP server. Your username and password are provided by your web host. If you don\u2019t know them, check your email to find the information when they &#8211; probably &#8211; sent it when you set up your website. Alternatively, contact your host via live chat and ask for this information.)<\/p><ol start=\"2\"><li><strong> Go to the wp-config.php file.<\/strong> Open the <strong>root file.<\/strong><\/li><\/ol><ol start=\"3\"><li><strong> Check the values under the following headlines:<\/strong><\/li><\/ol><div class=\"pop-out\"><p>Database Name<\/p><p>\/\/ ** MySQL settings ** \/\/<\/p><p>\/** The name of the database for WordPress *\/<\/p><p>define(&#8216;DB_NAME&#8217;, &#8216;xxxxxx&#8217;);<\/p><p><strong>MySQL database username<\/strong><\/p><p>\/** MySQL database username *\/<\/p><p>define(&#8216;DB_USER&#8217;, &#8216;xxxxxx&#8217;);<\/p><p><strong>MySQL database password<\/strong><\/p><p>\/** MySQL database password *\/<\/p><p>define(&#8216;DB_PASSWORD&#8217;, &#8216;xxxxxxxxx&#8217;);<\/p><p><strong>MySQL hostname (server)<\/strong><\/p><p>\/** MySQL hostname *\/<\/p><p>define(&#8216;DB_HOST&#8217;, &#8216;localhost&#8217;);<\/p><\/div><ol start=\"4\"><li><strong> Check the values against the values on your server.<\/strong><\/li><\/ol><ol start=\"5\"><li><strong> If the values are correct<\/strong>, they should be the same for your site and for your server. This means that something else is causing the issue, and you can skip to the next step.<\/li><\/ol><ol start=\"6\"><li><strong> If the values are different for your site and your server,<\/strong> you need to <strong>edit the values in your wp-config.php file <\/strong>to match those in your server.<\/li><\/ol><ol start=\"7\"><li>Once you\u2019ve updated the values to be correct, reload your WordPress website. It should work now!<\/li><\/ol><h4>Via cPanel<\/h4><p><img decoding=\"async\" class=\"aligncenter size-large wp-image-778\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/fix-error-using-cpanel-1024x419.jpg\" alt=\"\" width=\"1024\" height=\"419\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/fix-error-using-cpanel-1024x419.jpg 1024w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/fix-error-using-cpanel-300x123.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/fix-error-using-cpanel-768x314.jpg 768w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/fix-error-using-cpanel.jpg 1290w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p><p class=\"image-description\">Checking the database login credentials using cPanel is quite easy<\/p><p>To check your database login credentials using cPanel:<\/p><ol><li><strong> Go to cPanel &gt; Databases. <\/strong>Login to <strong>phpMyAdmin.<\/strong><\/li><\/ol><ol start=\"2\"><li>On the bottom-left side of the screen, you\u2019ll <strong>your database name.<\/strong> (Ignore <strong>information_schema database<\/strong>, it\u2019s used by the webhost and irrelevant to us right now!)<\/li><\/ol><ol start=\"3\"><li>Check the database name in cPanel and see if it matches the <strong>DB_NAME <\/strong>value in your <strong>wp-config.php<\/strong> file.<\/li><\/ol><ol start=\"5\"><li><strong> If the values are the same<\/strong>, something else is causing the issue, and you can skip to the next step.<\/li><\/ol><ol start=\"6\"><li><strong> If the values are different in cPanel and your wp-config.php file,<\/strong> you need to <strong>edit the values in your wp-config.php file <\/strong>to match those of your server.<\/li><\/ol><p>We can also check if the database is correct by seeing whether it contains the URL of your wordpress website. To do this:<\/p><ol><li><strong> Go to phpMyAdmin&gt; Database &gt; wp_options.<\/strong><\/li><\/ol><ol start=\"2\"><li>At the top part of the wp_options table, you\u2019ll see the information concerning the <strong>name<\/strong> and <strong>URL<\/strong> of your website. See if they are correct and match your website data.<\/li><\/ol><ol start=\"3\"><li><strong> If the database name was correct, <\/strong>but you\u2019re still seeing the error establishing a database connection, <strong>you need to check the username and password.<\/strong> So:<\/li><\/ol><ol start=\"4\"><li><strong> Go to the root directory<\/strong> of your WordPress website.<\/li><\/ol><ol start=\"5\"><li><strong> Create a new PHP file<\/strong> inside the root directory. Name it anything you like, but make sure to add the <strong>.php<\/strong> extension at the end (example: <strong>dbcheck.php<\/strong>).<\/li><\/ol><ol start=\"6\"><li><strong> Add the following code, <\/strong>only change the values of <strong>db_user<\/strong> and <strong>db_password<\/strong> so that they match the ones in your <strong>wp-config.php <\/strong>file.<\/li><\/ol><div class=\"pop-out\"><p><strong>&lt;?php<\/strong><br \/><strong>$test = mysqli_connect(&#8216;localhost&#8217;, &#8216;db_user&#8217;, &#8216;db_password&#8217;);<\/strong><br \/><strong>if (!$test) {<\/strong><br \/><strong>die(&#8216;MySQL Error: &#8216; . mysqli_error());<\/strong><br \/><strong>}<\/strong><br \/><strong>echo &#8216;Database connection is working properly!&#8217;;<\/strong><br \/><strong>mysqli_close($testConnection);<\/strong><\/p><\/div><ol start=\"7\"><li><strong> Go to <\/strong>the corresponding file on your WordPress file by visiting:<\/li><\/ol><p><strong>https:\/\/domainname.com\/dbcheck.php<\/strong>, where <strong>domainname <\/strong>is the name of your domain, and <strong>dbcheck<\/strong> is whatever you decided to name the new php folder.<\/p><ol start=\"8\"><li><strong> If the database issue was fixed by this point, <\/strong>you\u2019ll get the following message:<\/li><\/ol><p><strong>Database connection is working properly.<\/strong><\/p><ol start=\"9\"><li><strong>If there\u2019s a problem with your username and password credentials <\/strong>(or there\u2019s still an issue with establishing a database connection), you\u2019ll get the following error message:<\/li><\/ol><p><strong>MySQL Error: Access denied.<\/strong><\/p><p>To fix this, you\u2019ll need to <strong>reset your credentials<\/strong>. So let\u2019s keep moving!<\/p><ol><li>First, <strong>delete <\/strong>the test file, i.e. what we dubbed <strong>dbcheck.php.<\/strong><\/li><\/ol><ol start=\"2\"><li><strong> Go to cPanel &gt; Databases &gt; MySQL Databases.<\/strong><\/li><\/ol><ol start=\"3\"><li><strong> Create a new MySQL user<\/strong> at the bottom of the page. You may choose your own unique username and password, or allow the password generator tool do the job for you.<\/li><\/ol><p><strong>Alternatively, <\/strong>just change the <strong>password<\/strong> for the existing database user.<\/p><ol start=\"4\"><li>At the bottom of the list, <strong>add the<\/strong> <strong>new user<\/strong> to your <strong>database. <\/strong>The ensuing screen will allow you to choose which privileges you want to assign to the new user. Click on <strong>All Privileges.<\/strong><\/li><\/ol><ol start=\"5\"><li><strong> Update your wp-config.php<\/strong> file with the new credentials under the <strong>DB_USER <\/strong>and <strong>DB_PASSWORD <\/strong>values.<\/li><\/ol><ol start=\"6\"><li><strong> Repeat the PHP file test. <\/strong>If the issue was resolved, you\u2019ll now be getting the beautiful <strong>Database connection is working properly <\/strong>message.<\/li><\/ol><p>If you\u2019re still experiencing issues, the problem may be a wrong hostname (under <strong>DB_HOST<\/strong>). Most commonly, this value will say <strong>localhost. <\/strong>If you think this may be causing the issue, contact your host about it as soon as possible!<\/p><p>If checking and correcting your credentials didn\u2019t work in fixing the error establishing a database connection, let\u2019s move onto the next solution you can try to fix the issue.<\/p><h3 id=\"fix-corrupt-files\" class=\"c-anchor\">3. Fix Corrupt Files<\/h3><p>We will go over fixing two types of possibly corrupt files: a <strong>corrupt WordPress core version<\/strong> on your site or <strong>corrupt plugins\/themes files.<\/strong><\/p><p>In the first case, your WordPress core version files may become corrupt from a number of reasons, including:<\/p><ul><li>Hackers getting a hold of your site information;<\/li><li>Glitches during migration from one host to another;<\/li><li>Host-end issues;<\/li><li>Incorrectly transferred files via FTP client.<\/li><\/ul><p>In the second case, a certain plugin or theme file may have become corrupt in cases such as:<\/p><ul><li>A recent update;<\/li><li>A faulty connection with an external service;<\/li><li>An unintentional faulty edit in one of the theme or plugin folders on your end.<\/li><\/ul><p>Let\u2019s look at how you can fix the corrupt files in each case.<\/p><h4>How to Fix Corrupt Files in Your WordPress Core Version<\/h4><p>Before you continue with this step, make sure <strong>you backup<\/strong> your WordPress website.<\/p><p>What this solution basically entails is reinstalling the core version of WordPress for your website. Your other information, such as media, themes, and plugins, will remain untouched and can be retrieved when you reset your website.<\/p><p>To do this:<\/p><ol><li><strong> Go to the WordPress<\/strong> website and <a href=\"https:\/\/wordpress.org\/download\/\">download a new copy of WordPress<\/a>.<\/li><\/ol><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-780\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/WordPress-Download-1024x528.jpg\" alt=\"\" width=\"1024\" height=\"528\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/WordPress-Download-1024x528.jpg 1024w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/WordPress-Download-300x155.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/WordPress-Download-768x396.jpg 768w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/WordPress-Download.jpg 1342w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p><p class=\"image-description\">Download a new copy of the latest version of WordPress<\/p><ol start=\"2\"><li><strong> Unzip <\/strong>the WordPress file which downloaded on your PC.<\/li><\/ol><ol start=\"3\"><li><strong> Find and delete<\/strong> the <strong>wp-content <\/strong>folder and the <strong>wp-config-sample.php<\/strong> file.<\/li><\/ol><ol start=\"4\"><li><strong> Connect <\/strong>to your <strong>site via SFTP, <\/strong>and then <strong>upload the remainder of the files<\/strong> from the latest WordPress download. This step basically overwrites all the WordPress core version files, and if any of them were corrupt, they will no longer be a problem since they\u2019ll be replaced.<\/li><\/ol><ol start=\"5\"><li><strong> Flush your browser cache.<\/strong> To do this, go to <strong>Customize and control Google Chrome<\/strong> <strong>&gt; More Tools &gt; Clear browsing data.<\/strong> Check all boxes to flush your browser cache.<\/li><\/ol><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-613\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/How-to-clear-your-cache-and-cookies-in-Chrome.jpg\" alt=\"\" width=\"560\" height=\"456\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/How-to-clear-your-cache-and-cookies-in-Chrome.jpg 560w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/How-to-clear-your-cache-and-cookies-in-Chrome-300x244.jpg 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/p><p class=\"image-description\">How to clear your cache in Chrome<\/p><ol start=\"6\"><li><strong> Reload your website<\/strong>. If the issue was corrupt core WordPress files, the error establishing a database connection problem should now be resolved!<\/li><\/ol><h4>How to Fix Corrupt Files From Your Themes and Plugins<\/h4><p>Plugins and themes are created by web developers from across the globe, so it\u2019s not uncommon that they may cause glitches due to faulty codes or misconfigured updates.<\/p><p>We went over several different scenarios that may have resulted in a corrupt plugin or theme file. If your themes and plugins haven\u2019t recently gone through an update, you haven\u2019t connected your website to an external service, or weren\u2019t fumbling with the files, the chances that this is causing the issue are slim. If nothing else worked so far, however, there\u2019s no harm in trying!<\/p><h4>To fix corrupt files from your <strong>plugins<\/strong>:<\/h4><ol><li><strong> Connect to your host via FTP client.<\/strong><\/li><\/ol><ol start=\"2\"><li><strong> Go to the WordPress root folder<\/strong>, which may be named something like <strong>public_html<\/strong> or <strong>www<\/strong>. You may be directly inside the <strong>root folder<\/strong> upon connecting via FTP.<\/li><\/ol><ol start=\"3\"><li><strong> Navigate to the wp-content<\/strong> folder and find the <strong>plugins<\/strong> folder. <strong>Rename <\/strong>it to something else, like <strong>plugins_old.<\/strong><\/li><\/ol><ol start=\"4\"><li><strong> Reload your website, and see if the problem persists.<\/strong> If the error establishing a database connection message is gone, it means that one of your plugins was causing the issue, and we\u2019ll go on to find out which one. If the error message persists, <strong>change <\/strong>the folder\u2019s name back to <strong>plugins<\/strong>, because clearly plugins are not the culprit. Instead, you\u2019ll need to <strong>repeat the same process<\/strong> with the <strong>themes <\/strong>folder.<\/li><\/ol><ol start=\"5\"><li><strong> If the website loaded properly<\/strong>, we now need to find which exact plugin was causing the issue. To do this, we\u2019ll test each plugin one by one. <strong>Go back<\/strong> to FTP and rename your plugins folder back to <strong>plugins<\/strong>. This will <strong>reactivate <\/strong>all plugins.<\/li><\/ol><ol start=\"6\"><li>Rename each individual plugin folder one by one, so as to <strong>deactivate <\/strong>them individually. The easiest way to change each name is to just add an <strong>underscore (_) <\/strong>after each plugin\u2019s name. <strong>Reload <\/strong>your website after each deactivation.<\/li><\/ol><ol start=\"7\"><li>When your website <strong>loads<\/strong>, it means that the plugin that was <strong>deactivated<\/strong> at the time was the little bugger causing this whole mess. <strong>Delete it.<\/strong> Don\u2019t look back. Maybe contact the plugin\u2019s web developer to let them know there\u2019s an issue that should get fixed &#8211; if the problem was indeed a recent update.<\/li><\/ol><h4>To fix corrupt files from your <strong>themes<\/strong>:<\/h4><p>To fix potentially corrupt theme files, you\u2019ll need to <strong>deactivate <\/strong>your website\u2019s custom theme, and revert back to a default WordPress theme. These are the <strong>Twenty Somethings,<\/strong> like the <strong>Twenty Nineteen <\/strong>or the latest WordPress theme, <a href=\"https:\/\/wordpress.org\/themes\/twentytwenty\/\"><strong>Twenty Twenty<\/strong><\/a><strong>.<\/strong><\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-779\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/wordpress-theme-directory.jpg\" alt=\"\" width=\"1018\" height=\"590\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/wordpress-theme-directory.jpg 1018w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/wordpress-theme-directory-300x174.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/02\/wordpress-theme-directory-768x445.jpg 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/p><p class=\"image-description\">Deactivating a custom theme may fix the Error establishing a database connection problem<\/p><p>Deactivating themes is quite similar to deactivating plugins.<\/p><p>To do this:<\/p><ol><li><strong> Connect to your host via FTP client.<\/strong><\/li><\/ol><ol start=\"2\"><li>Find the <strong>wp_content\/themes<\/strong> folder.<\/li><\/ol><ol start=\"3\"><li>Rename it to anything, like <strong>themes_old<\/strong>. Renaming the <strong>themes<\/strong> folder will make WordPress revert back to the default theme. (<strong>Note:<\/strong> if you\u2019ve deleted the default themes from your WordPress account, just download any one of them from the WordPress repository and add it to your <strong>themes <\/strong>folder.)<\/li><\/ol><ol start=\"4\"><li><strong>Try loading your website again.<\/strong> If your website loads without a problem, it means that your custom theme was causing the error establishing a database connection. As we suggested earlier in the case of finding a faulty plugin, you can again contact the theme developer letting them know about the problem so they can fix it. You can also post a support ticket in the WordPress repository.<\/li><\/ol><p>If the error persists after renaming both the <strong>plugins<\/strong> and <strong>themes<\/strong> folders in your root directory, something else is causing the issue. The next step &#8211; which we\u2019ve been circling around for a while, is\u2026<\/p><h3 id=\"contact-your-web-hosting-provider\" class=\"c-anchor\">4. Contact Your Web Hosting Provider<\/h3><p>If nothing worked so far, your best bet is contacting your web host. The error establishing a database connection may be stemming from the database server. As we mentioned already, your host\u2019s server may be overloaded, especially if you\u2019re using a shared host. Too many website visitors may also be causing the issue, especially if you\u2019re on a budget plan that has a limit on the number of connections your website can generate at a given time.<\/p><h5><strong>Pro tip: <\/strong>To avoid this issue in the future, getting a caching plugin like <a href=\"https:\/\/wordpress.org\/plugins\/w3-total-cache\/\">W3 Total Cache<\/a> or <a href=\"https:\/\/wordpress.org\/plugins\/wp-super-cache\/\">WP Super Cache<\/a> can help reduce the database interaction on your website.<\/h5><p>Shared hosts use a limited amount of resources for a number of clients. If there are too many clients, and either you or someone else is getting a lot of website traffic, it may cause the entire server to go down and cause this issue.<\/p><p>You can contact your web host via live chat and get quick support, or open a ticket. If you\u2019re a DomainNameSanity client, <a href=\"https:\/\/support.domainnamesanity.com\/tickets\/create\/step1\">get in touch with us<\/a> and our tech support will check and resolve the problem in no time.<\/p><p>In the end, if your website is getting increasing numbers of visitors, it may be time for you to migrate to a slightly pricier plan. A better plan will provide you with more storage and support for heavier traffic and page weight.<\/p><h3 id=\"restore-your-website-to-the-latest-backup\" class=\"c-anchor\">5. Restore Your Website to the Latest Backup<\/h3><p>This step can be the last thing you try or the first, especially if you recently made a backup of your website.<\/p><p>If you recently backed up your website, and you don\u2019t think much important data will get lost in the process, <strong>try restoring your website to the latest backup version.<\/strong> You will probably need to restore your files and your database to complete the process.<\/p><p>If you\u2019re not sure how to do this, just contact your host. You host should have a backup restore procedure ready for you!<\/p><h3>Final Words<\/h3><p>While the <strong>Error establishing a database connection <\/strong>problem is frustrating, there are a number of ways to fix it. When you run your own website, it\u2019s inevitable to come across these sorts of error messages and other annoying glitches. As most of them aren\u2019t too difficult to fix, the best thing to do is try to get it done as soon as possible, so as not to lose any website traffic or drop in SEO rankings.<\/p><p>In the end, all you need to do is keep calm and read over our guide on how to fix the issue! Hopefully, one of our suggested solutions worked for you and your website is up and running again.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-02d9db7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"02d9db7\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e3db840\" data-id=\"e3db840\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-60a6169 article-end elementor-widget elementor-widget-spacer\" data-id=\"60a6169\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-565995e elementor-widget elementor-widget-heading\" data-id=\"565995e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">View Related Articles<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-21bb133 elementor-widget elementor-widget-spacer\" data-id=\"21bb133\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-404e6d4 elementor-posts__hover-none elementor-grid-3 elementor-grid-tablet-2 elementor-grid-mobile-1 elementor-posts--thumbnail-top elementor-card-shadow-yes elementor-widget elementor-widget-posts\" data-id=\"404e6d4\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;cards_masonry&quot;:&quot;yes&quot;,&quot;cards_columns&quot;:&quot;3&quot;,&quot;cards_columns_tablet&quot;:&quot;2&quot;,&quot;cards_columns_mobile&quot;:&quot;1&quot;,&quot;cards_row_gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:35,&quot;sizes&quot;:[]}}\" data-widget_type=\"posts.cards\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-posts-container elementor-posts elementor-posts--skin-cards elementor-grid\">\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-2545 post type-post status-publish format-standard has-post-thumbnail hentry category-fixing-errors\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/www.domainnamesanity.com\/blog\/why-are-my-emails-going-to-spam\/\" >\n\t\t\t<div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"640\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-1024x1024.jpg\" class=\"attachment-large size-large wp-image-2546\" alt=\"\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-1024x1024.jpg 1024w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-300x300.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-150x150.jpg 150w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-768x768.jpg 768w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-1536x1536.jpg 1536w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/spam-email-2048x2048.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/div>\n\t\t<\/a>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<h6 class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/www.domainnamesanity.com\/blog\/why-are-my-emails-going-to-spam\/\" >\n\t\t\t\tWhy Are My Emails Going to Spam?\t\t\t<\/a>\n\t\t<\/h6>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>There is no experience more frustrating than having your emails end up in the spam folder of your recipients rather than their inboxes. If you\u2019ve found that your emails are going to spam instead of your subscribers\u2019 inboxes, keep reading to find out why.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-2525 post type-post status-publish format-standard has-post-thumbnail hentry category-fixing-errors\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/www.domainnamesanity.com\/blog\/how-to-become-tech-savvy\/\" >\n\t\t\t<div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"518\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-1024x828.jpg\" class=\"attachment-large size-large wp-image-2523\" alt=\"\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-1024x828.jpg 1024w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-300x243.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-768x621.jpg 768w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-1536x1243.jpg 1536w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2023\/07\/tech-savvy-person-2048x1657.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/div>\n\t\t<\/a>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<h6 class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/www.domainnamesanity.com\/blog\/how-to-become-tech-savvy\/\" >\n\t\t\t\tHow to Become Tech Savvy\t\t\t<\/a>\n\t\t<\/h6>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>In a world where technology shapes our society and everyday life, knowing how to operate a computer and other common tech gadgets becomes a survival skill. <\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-2412 post type-post status-publish format-standard has-post-thumbnail hentry category-fixing-errors\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/www.domainnamesanity.com\/blog\/what-two-protocols-are-used-to-deliver-mail-messages\/\" >\n\t\t\t<div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-1024x768.jpg\" class=\"attachment-large size-large wp-image-1827\" alt=\"\" srcset=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-1024x768.jpg 1024w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-300x225.jpg 300w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-768x576.jpg 768w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-1536x1152.jpg 1536w, https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/07\/catch-all-email-2048x1536.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/div>\n\t\t<\/a>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<h6 class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/www.domainnamesanity.com\/blog\/what-two-protocols-are-used-to-deliver-mail-messages\/\" >\n\t\t\t\tWhat two protocols are used to deliver mail messages?\t\t\t<\/a>\n\t\t<\/h6>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Emailing today is such an easy task. Compose, hit send, and your message travels across oceans and borders to reach its recipient. It is such an easy task that people\u2019s attention starts to drown in their full inboxes, which are also littered by spammers, phishers and other members of the not-so-nice population of netizens.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0b4fddc elementor-widget elementor-widget-spacer\" data-id=\"0b4fddc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Nothing short of finding you\u2019ve run out of coffee in the morning can be as frustrating as finding \u201cError establishing a database connection\u201d on your WordPres website. This error code indicates that your website has lost access to your WordPress database, and so it has gone&#8230;<\/p>\n","protected":false},"author":2,"featured_media":638,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fixing-errors"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog<\/title>\n<meta name=\"description\" content=\"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog\" \/>\n<meta property=\"og:description\" content=\"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Domain Name Sanity Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-04T05:08:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-06T06:32:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Douglas Moore\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Douglas Moore\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/\"},\"author\":{\"name\":\"Douglas Moore\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/#\\\/schema\\\/person\\\/da394e5c6329f3cff53724f73fb22a7b\"},\"headline\":\"5 Fixes for Error Establishing a Database Connection in WordPress\",\"datePublished\":\"2020-02-04T05:08:05+00:00\",\"dateModified\":\"2020-04-06T06:32:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/\"},\"wordCount\":3608,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/fix-error-establishing-database-connection-wordpress.png\",\"articleSection\":[\"Fixing Errors\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/\",\"url\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/\",\"name\":\"5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/fix-error-establishing-database-connection-wordpress.png\",\"datePublished\":\"2020-02-04T05:08:05+00:00\",\"dateModified\":\"2020-04-06T06:32:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/#\\\/schema\\\/person\\\/da394e5c6329f3cff53724f73fb22a7b\"},\"description\":\"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/fix-error-establishing-database-connection-wordpress.png\",\"contentUrl\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/fix-error-establishing-database-connection-wordpress.png\",\"width\":900,\"height\":675},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/how-to-fix-error-establishing-a-database-connection-in-wordpress\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"5 Fixes for Error Establishing a Database Connection in WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/\",\"name\":\"Domain Name Sanity Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/#\\\/schema\\\/person\\\/da394e5c6329f3cff53724f73fb22a7b\",\"name\":\"Douglas Moore\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/douglas-m-150x150.jpg\",\"url\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/douglas-m-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/www.domainnamesanity.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/douglas-m-150x150.jpg\",\"caption\":\"Douglas Moore\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog","description":"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog","og_description":"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.","og_url":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/","og_site_name":"Domain Name Sanity Blog","article_published_time":"2020-02-04T05:08:05+00:00","article_modified_time":"2020-04-06T06:32:56+00:00","og_image":[{"width":900,"height":675,"url":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png","type":"image\/png"}],"author":"Douglas Moore","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Douglas Moore","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/"},"author":{"name":"Douglas Moore","@id":"https:\/\/www.domainnamesanity.com\/blog\/#\/schema\/person\/da394e5c6329f3cff53724f73fb22a7b"},"headline":"5 Fixes for Error Establishing a Database Connection in WordPress","datePublished":"2020-02-04T05:08:05+00:00","dateModified":"2020-04-06T06:32:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/"},"wordCount":3608,"commentCount":0,"image":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png","articleSection":["Fixing Errors"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/","url":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/","name":"5 Fixes for Error Establishing a Database Connection in WordPress - Domain Name Sanity Blog","isPartOf":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png","datePublished":"2020-02-04T05:08:05+00:00","dateModified":"2020-04-06T06:32:56+00:00","author":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/#\/schema\/person\/da394e5c6329f3cff53724f73fb22a7b"},"description":"Learn what image optimization is and get some tips on how to optimize the images on your website for better performance.","breadcrumb":{"@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#primaryimage","url":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png","contentUrl":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2020\/01\/fix-error-establishing-database-connection-wordpress.png","width":900,"height":675},{"@type":"BreadcrumbList","@id":"https:\/\/www.domainnamesanity.com\/blog\/how-to-fix-error-establishing-a-database-connection-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.domainnamesanity.com\/blog\/"},{"@type":"ListItem","position":2,"name":"5 Fixes for Error Establishing a Database Connection in WordPress"}]},{"@type":"WebSite","@id":"https:\/\/www.domainnamesanity.com\/blog\/#website","url":"https:\/\/www.domainnamesanity.com\/blog\/","name":"Domain Name Sanity Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.domainnamesanity.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.domainnamesanity.com\/blog\/#\/schema\/person\/da394e5c6329f3cff53724f73fb22a7b","name":"Douglas Moore","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/douglas-m-150x150.jpg","url":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/douglas-m-150x150.jpg","contentUrl":"https:\/\/www.domainnamesanity.com\/blog\/wp-content\/uploads\/2019\/12\/douglas-m-150x150.jpg","caption":"Douglas Moore"}}]}},"_links":{"self":[{"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":8,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":1078,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/posts\/775\/revisions\/1078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/media\/638"}],"wp:attachment":[{"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.domainnamesanity.com\/blog\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}