Database connection errors are among the most common issues that can interrupt a website, especially on hosting platforms where the application, control panel, and database service must all work together correctly. In many cases, the problem is not a damaged database, but a mismatch in credentials, host settings, permissions, server limits, or a temporary service issue. If your site is hosted on a managed platform or in a control panel such as Plesk, most of these checks can be completed quickly without advanced database administration.
This guide explains how to identify the cause of a MySQL database connection error, how to fix the most frequent problems, and how to reduce the chance of the same issue happening again. The steps apply well to typical shared hosting, managed hosting, and EU-based hosting environments where websites depend on MySQL or MariaDB databases.
What a database connection error usually means
A database connection error appears when the website cannot open a working connection to MySQL. In practical terms, the application tried to log in to the database but failed. This can happen during normal site loading, during login pages, checkout flows, or any page that reads content from the database.
Typical messages include:
- “Error establishing a database connection”
- “Access denied for user”
- “Can’t connect to MySQL server”
- “Unknown database”
- “Too many connections”
Although the wording differs, the root cause is usually one of the following: incorrect credentials, wrong database host, missing privileges, a full connection limit, or a temporary outage on the database service.
Check the most common causes first
Before changing anything, confirm whether the issue is site-wide or limited to one application. On hosting platforms, a single website may fail while other sites continue working normally. That often means the problem is local to the application configuration rather than the entire database server.
1. Verify the database name, username, and password
This is the most common cause. If the application cannot authenticate, it cannot connect.
Check the configuration file used by your website:
- WordPress:
wp-config.php - Joomla: configuration file in the site root
- Drupal:
settings.php - Custom PHP apps: often
.env,config.php, or similar
Make sure the following values are correct:
- Database name
- Database username
- Database password
- Database host
If you recently changed the password in the control panel or Plesk, update the application config immediately. Even one incorrect character will prevent the login.
2. Confirm the database host is correct
Many hosting users assume the database host should always be localhost. That is sometimes correct, but not always. Some hosting environments use a dedicated internal host name or IP address for MySQL connections.
Check your hosting control panel for the exact database host value. If the platform provides a database management page, it may list the host explicitly. In managed hosting, the correct host can differ depending on the plan, server architecture, or security settings.
If your app is configured with the wrong host, you may see errors such as:
- Connection timed out
- Unknown MySQL server host
- Unable to connect to database
3. Make sure the database user has permissions
A valid username and password are not enough if the database user does not have access to the target database. This happens frequently after migrations, restores, or manual changes in the control panel.
Check that the user is assigned to the database and has the required privileges. For a normal website, the user usually needs permissions such as:
- SELECT
- INSERT
- UPDATE
- DELETE
- CREATE
- ALTER
- INDEX
In Plesk or similar panels, verify the database-user assignment and confirm that the user is linked to the correct database, not just present in the account.
How to fix a database connection error step by step
The following sequence is the safest way to troubleshoot most MySQL connection issues on a hosting platform.
Step 1: Check whether the database server is available
First, determine if the database service itself is running. If the service is down, every site that depends on it may fail to connect.
Look for signs such as:
- Multiple websites returning the same database error
- Database tools in the control panel loading slowly or failing
- Admin access to phpMyAdmin not working
- Connection errors appearing after a server alert or maintenance event
If you have access to the hosting status page, service monitor, or support notifications, check whether MySQL/MariaDB is currently affected. In managed hosting, the provider may already be handling service recovery.
Step 2: Test the credentials in the control panel
Open the database management section in your hosting control panel and confirm the following:
- The database exists
- The user exists
- The password is known and current
- The user is assigned to the database
If the password is uncertain, reset it in the control panel and then update the website configuration file. Make sure you save the changes carefully, because database passwords are case-sensitive.
Step 3: Review the application config file
For most website applications, the connection details are stored in one central config file. Open it and compare the settings with the values in the control panel.
Common problems include:
- Database name has a prefix you missed
- Username is missing the account prefix
- Password was changed in the control panel but not in the config file
- Host is set to
localhostwhen the server requires another value - There is an extra space or hidden character in the config file
In PHP-based applications, even a small formatting issue in the config file can break the connection. If the file was edited manually, re-check the syntax carefully.
Step 4: Confirm the database name exists
After migrations, restores, or staging-to-production deployments, it is possible for the app to point to a database that does not exist anymore. The error message may say the database is missing or unknown.
Check the database list in your hosting panel and make sure the exact database name matches the config file. If the database was renamed, recreated, or imported under another name, update the app accordingly.
Step 5: Repair the database tables if needed
If the connection works but the website still fails, the issue may be damaged tables or a corrupted database structure. This is less common than a wrong password, but it can happen after crashes, interrupted imports, or disk-related problems.
In MySQL management tools, you may be able to:
- Check tables for errors
- Repair tables
- Optimize tables
For WordPress and other PHP applications, built-in repair options may exist, but use them carefully and only when the connection is partially working or when database access is still possible through phpMyAdmin.
Step 6: Check for connection limit issues
On shared hosting or busy sites, the database may refuse new connections if the account has reached its limit. This can happen during traffic spikes, broken scripts, bots, or inefficient queries.
Possible signs include:
- Intermittent database errors
- Site works for some visitors but not others
- Errors occur during peak traffic periods
- Hosting logs show “too many connections”
To reduce pressure, review caching, disable unnecessary plugins, and check whether a custom script is opening too many database connections. If your hosting plan has a low limit, you may need optimization or an upgrade.
How to troubleshoot in Plesk
If your hosting account uses Plesk, database troubleshooting is usually straightforward because user, database, and privilege settings are visible in one place.
Check database details in Plesk
Go to the database section and confirm:
- The database name is correct
- The database user is assigned
- The password is current
- The connection host matches the application config
Use phpMyAdmin to verify access
Open phpMyAdmin from Plesk and try logging in through the database user. If phpMyAdmin also fails, the issue is likely with the credentials, privileges, or server access rather than the website application itself.
Review subscription limits and permissions
In some managed environments, connection limits, disk quotas, or resource restrictions can affect database behavior. If the account is near its limits, MySQL may become slow or unresponsive. Check the subscription usage, PHP limits, and any resource alerts available in the panel.
How to handle application-specific errors
Some platforms display generic database messages, while others provide clues tied to the app.
WordPress
For WordPress, the most common cause is wrong credentials in wp-config.php. Verify:
DB_NAMEDB_USERDB_PASSWORDDB_HOST
If the database is correct but the site still does not load, check for plugin or theme issues that create excessive database activity. A corrupted plugin update can also trigger repeated connection attempts.
Joomla and Drupal
These systems usually store database settings in configuration files that can be edited manually. After restoring a backup or moving the site, confirm that the database prefix, host, and credentials match the live database.
Custom PHP applications
Custom code often uses environment variables or framework config files. Verify that the application is pointing to the correct database server and that the connection library uses the expected charset and port.
When the error appears after migration or restore
Database connection issues often show up after a site migration, backup restore, or domain change. In these cases, the application may still contain old connection details from the previous hosting environment.
Common migration-related checks:
- Database imported successfully
- Database user recreated with the same privileges
- Config file updated with new credentials
- Database host changed if required by the new platform
- Table prefix matches the imported structure
If the restore included files but not the database, the site will not be able to connect. Make sure both parts were restored together.
How to isolate whether the problem is the site or the server
A useful way to troubleshoot is to ask a simple question: is the issue affecting one application or all databases on the account?
- One site only usually means wrong config, missing privileges, or app-level corruption.
- Multiple sites on the same hosting account can point to resource limits or a shared database service issue.
- All sites and phpMyAdmin fail may indicate a server-level MySQL outage or maintenance event.
This distinction helps you avoid unnecessary changes. If the issue is server-side, changing application settings will not help until the database service is available again.
Preventing future database connection errors
Once the site is back online, take a few preventive steps to reduce the risk of recurrence.
- Keep a secure record of database names and usernames.
- Update config files immediately after password changes.
- Use strong but documented credentials in managed environments.
- Avoid unnecessary manual edits in config files.
- Review plugin, theme, or script behavior that causes heavy query load.
- Monitor resource usage if your hosting plan includes limits.
- Test backups regularly so you can restore cleanly if corruption occurs.
For websites with traffic growth, caching can also reduce database load and improve stability. On hosting platforms where the database and web server share resources, this can make a noticeable difference.
Quick checklist before contacting support
If you still see the error after basic checks, collect the following details before opening a support request. This helps technical support diagnose the issue faster.
- The exact error message
- The affected domain or application
- Whether one site or multiple sites are affected
- Recent changes made before the error started
- Whether the database password was changed
- Whether the issue started after a migration or restore
- Any screenshots from the control panel or phpMyAdmin
Providing the error text and a timeline of recent changes often shortens resolution time significantly.
FAQ
Why does my website show “Error establishing a database connection”?
This usually means the site cannot log in to MySQL. The most common reasons are an incorrect database name, username, password, host, or missing privileges.
Is this always a server outage?
No. In many cases the server is working normally and the issue is only in the website configuration. Check the credentials and host before assuming there is a platform-wide failure.
Can I fix this in the hosting control panel?
Yes, often you can. In Plesk or another control panel, you can verify database details, reset the password, assign the user to the database, and test access with phpMyAdmin.
What if the password was changed recently?
Update the application configuration file immediately. If the password in the config file does not match the control panel, the connection will fail.
Why does the site work in the admin area but not on the front end?
This can happen if the front end triggers heavier database usage, if a plugin is misbehaving, or if caching masks the issue in some areas. Check logs and resource usage to find the source.
Can a corrupted database cause connection errors?
Yes, but less often than credential problems. Corrupted tables or an interrupted import can produce errors that look like connection failures or make the app unusable even when credentials are correct.
Should I repair the database myself?
If you are using a managed hosting platform, repair options may be available in the control panel or through phpMyAdmin. Only use repair tools if you understand the risk and have a backup available.
Conclusion
Most database connection errors can be solved by checking four things: the database name, username, password, and host. In a hosting or Plesk environment, it is also important to confirm that the database user has the right privileges and that the database service itself is available. If the error began after a migration, restore, or password reset, the cause is usually a configuration mismatch rather than a deeper technical fault.
By following the steps in this guide, you can diagnose the issue systematically, restore the connection faster, and keep your website stable on a managed hosting platform.