{"id":128,"date":"2026-05-26T20:58:09","date_gmt":"2026-05-26T20:58:09","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/"},"modified":"2026-05-26T20:58:09","modified_gmt":"2026-05-26T20:58:09","slug":"fix-error-establishing-a-database-connection-wordpress","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/","title":{"rendered":"Fix &#8220;Error Establishing a Database Connection&#8221; in WordPress"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>The <strong>Error Establishing a Database Connection<\/strong> is one of the most disruptive errors in WordPress. It takes down your entire site \u2014 front end and wp-admin \u2014 and gives you almost no information about what actually went wrong. That&#8217;s what makes it frustrating.<\/p>\n<p>At its core, the error means WordPress tried to connect to MySQL and failed. That could be wrong credentials in <code class=\"\" data-line=\"\">wp-config.php<\/code>, a crashed MySQL service, a corrupted database, or a misconfigured hostname. Each cause has a different fix, so the goal is to work through them in order \u2014 fastest to diagnose first.<\/p>\n<p>This article is written for WordPress sites on shared hosting, VPS, and dedicated servers. Some steps require SSH or cPanel access. If you&#8217;re on our <a href=\"https:\/\/www.hostandtech.com\/managed-wordpress-hosting\/\">Managed WordPress Hosting<\/a>, open a support ticket instead \u2014 we handle MySQL-level issues on your behalf.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>FTP, SFTP, or File Manager access to your WordPress root directory<\/li>\n<li>cPanel, Plesk, or WHM access (for checking MySQL databases and users)<\/li>\n<li>SSH access (recommended for faster diagnosis \u2014 not required for all steps)<\/li>\n<li>Your current <code class=\"\" data-line=\"\">wp-config.php<\/code> database credentials (or access to retrieve them)<\/li>\n<li>WordPress 5.x or later (steps are the same for 6.x)<\/li>\n<\/ul>\n<h2>Step-by-Step Instructions<\/h2>\n<h3>Step 1: Check Whether wp-admin Is Also Down<\/h3>\n<p>Visit <code class=\"\" data-line=\"\">https:\/\/yourdomain.com\/wp-admin<\/code> directly. If you see the same error there, the problem is a genuine database connectivity issue \u2014 not a theme or plugin problem on the front end only. If wp-admin loads but the front end doesn&#8217;t, skip to the troubleshooting section and look at the corrupted database table issue.<\/p>\n<h3>Step 2: Verify Your Database Credentials in wp-config.php<\/h3>\n<p>Wrong credentials are the most common cause, especially after a site migration or a hosting account change. Open your <code class=\"\" data-line=\"\">wp-config.php<\/code> file \u2014 it&#8217;s in the root of your WordPress installation, typically <code class=\"\" data-line=\"\">\/home\/username\/public_html\/wp-config.php<\/code> on cPanel hosts.<\/p>\n<p>Look for these four lines:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-1\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-1'><code class=\"\" data-line=\"\">define( &#039;DB_NAME&#039;, &#039;your_database_name&#039; );\ndefine( &#039;DB_USER&#039;, &#039;your_database_user&#039; );\ndefine( &#039;DB_PASSWORD&#039;, &#039;your_database_password&#039; );\ndefine( &#039;DB_HOST&#039;, &#039;localhost&#039; );<\/code><\/pre>\n<\/div>\n<p>Now cross-reference each value against your actual MySQL database in cPanel:<\/p>\n<ol>\n<li>Log in to cPanel and go to <strong>MySQL Databases<\/strong>.<\/li>\n<li>Under <em>Current Databases<\/em>, confirm the database name matches <code class=\"\" data-line=\"\">DB_NAME<\/code> exactly \u2014 including any cPanel username prefix (e.g. <code class=\"\" data-line=\"\">htuser_wpdb<\/code>).<\/li>\n<li>Under <em>Current Users<\/em>, confirm the username matches <code class=\"\" data-line=\"\">DB_USER<\/code>.<\/li>\n<li>Click <strong>Check Password<\/strong> next to the user to verify the password in <code class=\"\" data-line=\"\">wp-config.php<\/code> is correct. If it&#8217;s wrong, update it here or update <code class=\"\" data-line=\"\">wp-config.php<\/code> to match.<\/li>\n<li>Confirm the user is assigned to the database under <em>Add User to Database<\/em> \u2014 assigned with <strong>All Privileges<\/strong>.<\/li>\n<\/ol>\n<p>\ud83d\udcdd Note: On WHM-managed servers, database usernames are prefixed with the cPanel account name. If you migrated from a server without that prefix, this is almost certainly your problem.<\/p>\n<h3>Step 3: Test the DB_HOST Value<\/h3>\n<p><code class=\"\" data-line=\"\">localhost<\/code> works on most shared hosting and single-server VPS setups. But there are cases where it won&#8217;t:<\/p>\n<ul>\n<li>Some hosts require a socket path instead of a hostname<\/li>\n<li>If MySQL is running on a separate database server (common on VPS clusters or dedicated setups), <code class=\"\" data-line=\"\">DB_HOST<\/code> needs to be the internal IP or hostname of that server<\/li>\n<li>Non-standard MySQL ports need to be specified as <code class=\"\" data-line=\"\">localhost:3308<\/code> (or whatever port applies)<\/li>\n<\/ul>\n<p>Check your hosting welcome email or control panel for the correct database host value if <code class=\"\" data-line=\"\">localhost<\/code> isn&#8217;t working.<\/p>\n<h3>Step 4: Check Whether MySQL Is Actually Running<\/h3>\n<p>If credentials are correct and the host value is right, MySQL itself may be down. This happens after server crashes, resource exhaustion, or failed updates.<\/p>\n<p>Via SSH, run:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-2\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-2'><code class=\"\" data-line=\"\">sudo systemctl status mysql\n# or on servers using MariaDB:\nsudo systemctl status mariadb<\/code><\/pre>\n<\/div>\n<p>If the service is stopped or failed, restart it:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-3\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-3'><code class=\"\" data-line=\"\">sudo systemctl restart mysql\n# or:\nsudo systemctl restart mariadb<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: If MySQL crashes repeatedly within minutes of restarting, don&#8217;t keep restarting it. Check <code class=\"\" data-line=\"\">\/var\/log\/mysql\/error.log<\/code> for the actual reason. A common culprit is the server running out of memory \u2014 on a VPS, this usually means you&#8217;ve outgrown your current plan.<\/p>\n<p>If you don&#8217;t have SSH access, log in to WHM and go to <strong>Restart Services &gt; SQL Server (MySQL)<\/strong>.<\/p>\n<h3>Step 5: Run the WordPress Database Repair Tool<\/h3>\n<p>If MySQL is running but the connection still fails \u2014 or if wp-admin throws a &#8220;One or more database tables are unavailable&#8221; error \u2014 one or more tables may be corrupted.<\/p>\n<p>Enable the repair tool by adding this line to <code class=\"\" data-line=\"\">wp-config.php<\/code>, just before the <code class=\"\" data-line=\"\">\/* That&#039;s all, stop editing! *\/<\/code> line:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-4\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-4'><code class=\"\" data-line=\"\">define( &#039;WP_ALLOW_REPAIR&#039;, true );<\/code><\/pre>\n<\/div>\n<p>Then visit:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-5\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-5'><code class=\"\" data-line=\"\">https:\/\/yourdomain.com\/wp-admin\/maint\/repair.php<\/code><\/pre>\n<\/div>\n<p>Click <strong>Repair and Optimize Database<\/strong>. Once it finishes, remove the <code class=\"\" data-line=\"\">WP_ALLOW_REPAIR<\/code> line from <code class=\"\" data-line=\"\">wp-config.php<\/code> immediately.<\/p>\n<p>\u26a0 Warning: Leave <code class=\"\" data-line=\"\">WP_ALLOW_REPAIR<\/code> enabled and anyone can run the repair tool against your database without logging in. Remove it as soon as you&#8217;re done.<\/p>\n<h3>Step 6: Check File Permissions on wp-config.php<\/h3>\n<p>This one gets overlooked. If <code class=\"\" data-line=\"\">wp-config.php<\/code> has incorrect permissions, PHP can&#8217;t read it and the database credentials never get passed to WordPress.<\/p>\n<p>The correct permission is <code class=\"\" data-line=\"\">640<\/code> or <code class=\"\" data-line=\"\">644<\/code>. Via SSH:<\/p>\n<div class='ht-code-snippet'><button class='ht-code-snippet__copy' onclick='htCopyCode(\"code-block-6\")' type='button' aria-label='Copy code'><svg class='ht-copy-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z'><\/path><path d='M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z'><\/path><\/svg><svg class='ht-check-icon' viewBox='0 0 32 32' width='16' height='16' fill='currentColor'><path d='M13,24l-9-9,1.414-1.414L13,21.171,26.586,7.586,28,9Z'><\/path><\/svg><\/button><span class='ht-code-snippet__feedback'>Copied to clipboard<\/span><\/p>\n<pre class='ht-code-snippet__code' id='code-block-6'><code class=\"\" data-line=\"\">ls -la \/home\/username\/public_html\/wp-config.php\nchmod 640 \/home\/username\/public_html\/wp-config.php<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: Some security guides recommend <code class=\"\" data-line=\"\">400<\/code> (owner read-only). That&#8217;s fine as long as PHP runs as the file owner, which is the case on most cPanel setups using suPHP or suEXEC. On servers where PHP runs as <code class=\"\" data-line=\"\">www-data<\/code> or <code class=\"\" data-line=\"\">apache<\/code>, you may need <code class=\"\" data-line=\"\">644<\/code>.<\/p>\n<h2>Common Issues &amp; Troubleshooting<\/h2>\n<h3>Correct Credentials but Still Getting the Error<\/h3>\n<p>The credentials in <code class=\"\" data-line=\"\">wp-config.php<\/code> match the database panel exactly, but the error persists. Nine times out of ten, the MySQL user hasn&#8217;t actually been granted privileges on that database. In cPanel, go to <strong>MySQL Databases<\/strong>, scroll to <strong>Add User to Database<\/strong>, select the user and database, and grant <strong>All Privileges<\/strong>. This step is separate from creating the user and is frequently skipped during manual setups.<\/p>\n<h3>Error Only Appears Intermittently<\/h3>\n<p>If the site loads fine sometimes and throws the error other times, the database is likely hitting its connection limit. This is common on shared hosting plans with high-traffic WordPress sites, or on VPS instances where the <code class=\"\" data-line=\"\">max_connections<\/code> value in MySQL is set too low. Check <code class=\"\" data-line=\"\">\/etc\/mysql\/my.cnf<\/code> or <code class=\"\" data-line=\"\">\/etc\/my.cnf<\/code> for the <code class=\"\" data-line=\"\">max_connections<\/code> setting. A persistent fix usually means either optimising queries (a caching plugin like WP Super Cache helps) or upgrading your hosting plan.<\/p>\n<h3>wp-admin Loads but Frontend Shows the Error<\/h3>\n<p>This is almost always a corrupted <code class=\"\" data-line=\"\">wp_options<\/code> table rather than a true connection failure. Run the repair tool in Step 5 above. If that doesn&#8217;t clear it, connect to the database directly via phpMyAdmin and check the <code class=\"\" data-line=\"\">wp_options<\/code> table for obvious corruption or missing rows for <code class=\"\" data-line=\"\">siteurl<\/code> and <code class=\"\" data-line=\"\">home<\/code>.<\/p>\n<h3>Error After Migrating WordPress to a New Host<\/h3>\n<p>Migrations are the number one trigger for this error. The database name and username on the new server almost certainly differ from the old one \u2014 especially if you&#8217;ve moved to a cPanel environment that prepends the account username. Update <code class=\"\" data-line=\"\">wp-config.php<\/code> with the new values. Also double-check that the database was actually imported; it&#8217;s easy to move the files without importing the <code class=\"\" data-line=\"\">.sql<\/code> dump.<\/p>\n<h3>MySQL Service Keeps Crashing<\/h3>\n<p>Look at <code class=\"\" data-line=\"\">\/var\/log\/mysql\/error.log<\/code> \u2014 don&#8217;t guess. Common causes include the InnoDB buffer pool being set too high for available RAM, a full disk partition (<code class=\"\" data-line=\"\">df -h<\/code> will show this immediately), or a corrupted InnoDB tablespace. If the disk is full, that&#8217;s your answer. If it&#8217;s a memory issue and you&#8217;re on a VPS, I&#8217;d recommend reviewing your MySQL configuration or considering a plan with more RAM before the crashes start causing data loss.<\/p>\n<h2>FAQ<\/h2>\n<div class='ht-faq-section'>\n<h2>Frequently Asked Questions<\/h2>\n<div class='ht-faq-item'>\n<h3 class='ht-faq-question'>How do I find my WordPress database name and password?<\/h3>\n<div class='ht-faq-answer'>\n<p>Open <code class=\"\" data-line=\"\">wp-config.php<\/code> in your WordPress root directory \u2014 it&#8217;s usually at <code class=\"\" data-line=\"\">\/home\/username\/public_html\/wp-config.php<\/code>. The database name, username, and password are defined near the top of the file with <code class=\"\" data-line=\"\">DB_NAME<\/code>, <code class=\"\" data-line=\"\">DB_USER<\/code>, and <code class=\"\" data-line=\"\">DB_PASSWORD<\/code>. You can also find them in cPanel under MySQL Databases.<\/p>\n<\/div>\n<\/div>\n<div class='ht-faq-item'>\n<h3 class='ht-faq-question'>Will fixing this error delete my WordPress content?<\/h3>\n<div class='ht-faq-answer'>\n<p>No \u2014 none of the steps in this guide delete database content. The repair tool in Step 5 repairs corrupted table structures but doesn&#8217;t remove posts, pages, or settings. That said, always take a database backup before making changes, especially if you&#8217;re editing wp-config.php or running repairs on a live site.<\/p>\n<\/div>\n<\/div>\n<div class='ht-faq-item'>\n<h3 class='ht-faq-question'>Why does this error only show up sometimes and not others?<\/h3>\n<div class='ht-faq-answer'>\n<p>Intermittent database connection errors are usually caused by MySQL hitting its maximum connection limit under load. When traffic spikes, new connections get refused. A caching plugin can significantly reduce the number of database queries on each page load, which helps. If it keeps happening, the site has likely outgrown its current hosting plan.<\/p>\n<\/div>\n<\/div>\n<div class='ht-faq-item'>\n<h3 class='ht-faq-question'>Can a WordPress plugin cause this error?<\/h3>\n<div class='ht-faq-answer'>\n<p>A plugin can&#8217;t break the database connection itself, but a buggy plugin can corrupt a database table \u2014 particularly <code class=\"\" data-line=\"\">wp_options<\/code> \u2014 which triggers this error on the front end. If the error appeared right after installing or updating a plugin, use the WordPress repair tool and then deactivate that plugin via FTP by renaming its folder in <code class=\"\" data-line=\"\">\/wp-content\/plugins\/<\/code>.<\/p>\n<\/div>\n<\/div>\n<div class='ht-faq-item'>\n<h3 class='ht-faq-question'>What does DB_HOST should I use if localhost isn&#039;t working?<\/h3>\n<div class='ht-faq-answer'>\n<p>Check your hosting control panel or welcome email for the correct database hostname. On most single-server setups it&#8217;s <code class=\"\" data-line=\"\">localhost<\/code> or <code class=\"\" data-line=\"\">127.0.0.1<\/code>. On some managed hosting environments or clustered setups, it&#8217;ll be a specific internal hostname or IP address. If you&#8217;re on a Host &#038; Tech VPS or dedicated server and unsure, open a support ticket and we&#8217;ll confirm the correct value for your server configuration.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The &#8220;Error Establishing a Database Connection&#8221; message means WordPress can&#8217;t talk to your MySQL database \u2014 and it can be caused by half a dozen different things. This guide walks you through diagnosing the actual cause and fixing it, step by step.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[91],"tags":[132,134,135,131,129,133,121,130],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-database-credentials","tag-error-establishing-database-connection","tag-fix-error-establishing-a-database-connection-in-wordpress","tag-mysql-connection","tag-wordpress-database-error","tag-wordpress-repair","tag-wordpress-troubleshooting","tag-wp-config-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fix &quot;Error Establishing a Database Connection&quot; in WordPress<\/title>\n<meta name=\"description\" content=\"Seeing &quot;Error Establishing a Database Connection&quot; in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fix &quot;Error Establishing a Database Connection&quot; in WordPress\" \/>\n<meta property=\"og:description\" content=\"Seeing &quot;Error Establishing a Database Connection&quot; in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-26T20:58:09+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"Fix &#8220;Error Establishing a Database Connection&#8221; in WordPress\",\"datePublished\":\"2026-05-26T20:58:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/\"},\"wordCount\":1457,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"database credentials\",\"Error Establishing Database Connection\",\"Fix \\\"Error Establishing a Database Connection\\\" in WordPress\",\"MySQL connection\",\"wordpress database error\",\"WordPress repair\",\"WordPress troubleshooting\",\"wp-config.php\"],\"articleSection\":[\"WordPress Hosting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/\",\"name\":\"Fix \\\"Error Establishing a Database Connection\\\" in WordPress\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-05-26T20:58:09+00:00\",\"description\":\"Seeing \\\"Error Establishing a Database Connection\\\" in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wordpress\\\/fix-error-establishing-a-database-connection-wordpress\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fix &#8220;Error Establishing a Database Connection&#8221; in WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fix \"Error Establishing a Database Connection\" in WordPress","description":"Seeing \"Error Establishing a Database Connection\" in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.","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:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"Fix \"Error Establishing a Database Connection\" in WordPress","og_description":"Seeing \"Error Establishing a Database Connection\" in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.","og_url":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-05-26T20:58:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"Fix &#8220;Error Establishing a Database Connection&#8221; in WordPress","datePublished":"2026-05-26T20:58:09+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/"},"wordCount":1457,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["database credentials","Error Establishing Database Connection","Fix \"Error Establishing a Database Connection\" in WordPress","MySQL connection","wordpress database error","WordPress repair","WordPress troubleshooting","wp-config.php"],"articleSection":["WordPress Hosting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/","url":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/","name":"Fix \"Error Establishing a Database Connection\" in WordPress","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-05-26T20:58:09+00:00","description":"Seeing \"Error Establishing a Database Connection\" in WordPress? Follow this step-by-step guide to diagnose and fix the root cause fast.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/wordpress\/fix-error-establishing-a-database-connection-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"Fix &#8220;Error Establishing a Database Connection&#8221; in WordPress"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}