Application errors

    Error establishing a database connection: WordPress cannot reach its database

    Also searched as: wordpress database connection error · db connection error

    Is Error establishing a database connection happening on your domain?

    An external probe records whether the failure is constant or intermittent, and captures the exact minutes it occurs — which is what distinguishes wrong credentials from connection exhaustion.

    Free, no signup. Runs from outside your network, which is the only way to tell a server fault from a local one.

    Short answer

    WordPress loaded but could not connect to MySQL. Either the credentials in wp-config.php are wrong, the database server is down, or connections are exhausted under load.

    What Error establishing a database connection means

    This is WordPress's own message, printed before any theme loads. PHP is running fine — the failure is strictly between the application and the database.

    Causes and fixes, most likely first

    most common

    The database server is down or out of memory.

    Check the database service status and its error log. An out-of-memory kill on a small VPS is the classic cause of an intermittent version of this error.

    common

    Credentials in wp-config.php are wrong after a migration or a host password rotation.

    Verify DB_NAME, DB_USER, DB_PASSWORD and DB_HOST against the host's current values. DB_HOST is not always localhost on managed hosting.

    common

    The connection limit is exhausted under traffic.

    Raise max_connections or add persistent object caching so fewer requests hit the database. Intermittent failures at peak point straight here.

    occasional

    Database tables are corrupted.

    Enable WP_ALLOW_REPAIR in wp-config.php, run the repair page, then remove the flag immediately — it is unauthenticated while enabled.

    Error establishing a database connection on specific platforms and devices

    How to stop it happening again

    • •Monitor for the error string in the response body, not only for the HTTP status — WordPress often returns 500 or even 200 with this message.
    • •Alert on intermittent failures at peak traffic, which is the early signal of connection exhaustion.
    • •Add object caching before traffic grows, not after the first outage.

    Frequently asked questions

    Why is the error intermittent?

    Because the database is hitting its connection limit or being restarted by the out-of-memory killer under load. Constant failure means credentials or a stopped service; intermittent failure means capacity.

    How do I fix it after moving hosts?

    Update DB_HOST, DB_USER, DB_PASSWORD and DB_NAME in wp-config.php to the new host's values. DB_HOST is the field most often left as localhost when it should not be.

    Does this error hurt SEO?

    Yes, if it persists. Crawlers treat repeated failures as an unreliable site and reduce crawl rate. A short incident is harmless; a recurring one is not.

    Related errors

    Monitor this continuously with LemWatch

    A one-off error establishing a database connection monitoring shows you today. LemWatch re-runs the same checks around the clock and alerts you the moment something breaks — free for up to 10 sites, no card needed.

    Last verified: by the Lemwatch research team.