Few things are as frustrating as finding that your website is down — particularly if you rely on it for business. The Error Establishing a Database Connectionmessage represents a serious issue and prevents all access to your site, so fixing it is a top priority. However, if you’re not familiar with how WordPress works, it can be a confusing problem.
Don’t fret. Although this error is serious, it’s also highly fixable. With a few troubleshooting steps, you can have your site back online in no time. Here’s what we’ll cover:
- What is the Error Establishing a Database Connection?
- Common Causes of Database Connection Errors
- How to Fix the Error Establishing a Database Connection (4 Steps)
Let’s get started!
Got a WordPress Error? No Problem
You can skip troubleshooting if you sign up for DreamPress hosting. Our friendly WordPress experts are always standing by to solve your website problems — big or small.
Check Out Plans
Understanding the Error Establishing a Database Connection in WordPress
Before we dig too much into this particular error message, let’s have a brief lesson on how WordPress sites work. Nearly all website information — including post data, plugin settings, login credentials, and more — is stored and organized in a MySQL database.
MySQL
MySQL is a relational database management system that offers practical management tools. You can use MySQL to create, modify, and extract data from relational databases through the SQL programming language. It can also control the access that users have to the database.
Read More
When a visitor comes to your site, WordPress uses PHP to query the database and pull the correct information, which is then displayed as the complete page.
If, for whatever reason, WordPress can’t access your site’s database or it isn’t working properly, the result is an Error Establishing a Database Connection message.
This error prevents the entire page from loading. In fact, you won’t even be able to access the WordPress dashboard (your site’s back end).
If your site uses caching, visitors may still see stored copies of your pages. Therefore, if you catch the error early and resolve the problem before your site’s cache refreshes, you can avoid too many interruptions to your site and business.
Fortunately, as WordPress errors go, a database connection error is usually pretty simple to resolve. The most common cause, by far, is just a mismatch of login credentials for the database.
Related: How to Implement Caching on Your WordPress Website
Common Causes of the Error Establishing a Database Connection
There are four typical causes of the database connection error:
- Incorrect database login credentials.Possibly the most common cause of the Error Establishing a Database Connection is simply that WordPress has incorrect login credentials for your database. This could be either the database name, username, or password. Remember, these login details are different from the ones you use to access your site.
- Database corruption. A WordPress MySQL database contains a lotof information. If any part is deleted or corrupted, the result can be the error in question. Corruption can result from manually tinkering with the database, but it can also just happen as a consequence of normal use. Although MySQL is quite robust, nothing is perfect, and errors do occur.
- WordPress core file corruption. Similarly, corruption can occur in the core WordPress files that make up your site. Even though these files are outside the database, they may sometimes result in the same error.
- Problems with the web server or hosting provider.If problems arise with your host or server (if you’re self-hosting) and WordPress can’t reach it to query the database, it will throw this error. These problems can include outages, data loss, and hardware failures.
As we said, incorrect credentials are the most common cause of the error, but any of these could be the culprit. For that reason, fixing the error can involve some troubleshooting.
How to Fix the Error Establishing a Database Connection in WordPress (In 4 Steps)
Although this is a serious error, it’s fortunately fairly easy to resolve. Below, you’ll find step-by-step instructions for troubleshooting and fixing the problem. Note that you should try each step in order, only moving to the next if one doesn’t work.
Step 1: Check Your WordPress Database Credentials
Since this is the most likely cause of the error, it should also be the first step in your troubleshooting. The first thing you’ll need to do is locate the credentials WordPress is currently using to access your database.
This information is stored in your site’s wp-config.phpfile. You can use a Secure File Transfer Protocol (SFTP) clientto access it.
Alternatively, if your site is hosted with DreamHost, you can access the file system from the DreamHost Control Panel. To do so, sign in to your control panel and navigate to Domains > Websites. Hover the mouse over the domain you’d like to fix, then click ‘manage’ to see the folder icon. Then click on the file folder symbol next to the site that’s experiencing the error.
Inside the file browser, select the folder named after your website, then open wp-config.php. Here, look for three pieces of information — the database name, username, and password. They should be near the top of the file.
With this information in hand, head to your DreamHost Panel and navigate to More > MySQL Databases. Look for the hostname that corresponds to your website’s name. It will be formatted as mysql.yoursitename.com, with “yoursitename” being the name of your website.
If the hostname isn’t on this page, skip down to Step 2 and come back here when you’re done adding it.
In the section called Database(s) on this server, make sure the database name matches the one you pulled from wp-config.phpearlier. If it does, this isn’t the problem, and you can move on to the next step.
If it doesn’t match, go back to wp-config.php and update it with the correct database name.
Next, you can find the usernames that have access to each database beside their names on the MySQL Databasespage.
To view the password, click on the username. On the page that opens, scroll down to the Current Passwordfield and click on Show.
If the username or password doesn’t match your wp-config.phpfile,update it with the correct details. Alternatively, if the username matches but the password doesn’t, you could update the database password on the User Detailsscreen.
Step 2: Check Your Database Host Information
If you’ve checked the database login credentials and fixed any errors, but you’re still getting the Error Establishing a Database Connection message, the next thing you should check is your database host information.
The hostname for your database can be found in wp-config.php, right alongside the database name and login credentials.
Note this information, then head back to your DreamHost Panel and navigate to More > MySQL Databases. This time, you’re looking to make sure the hostname in your wp-config.phpfile is listed on this page. If it’s not, you’ll need to add it.
To add a hostname, simply click on the Add New Hostnamebutton. On the next page, enter the hostname you want to use and select the correct website domain from the dropdown.
When you’re finished, click on Create this MySQL hostname now!Note that it can take a few hours for this new hostname to propagate through the DNS, so feel free to take a break here. When some time has passed, come back and check if your site is working. If you’re still getting the database error message, proceed to the next step.
Step 3: Repair Your WordPress Database
If you’re still receiving the error message, you can try repairing the database to fix possible corruption. We recommend using the built-in WordPress database repair tool for this.
To access it, open up your wp-config.php file and add the following code at the end:
define('WP_ALLOW_REPAIR', true);
Next, open a new browser tab and navigate to https://yoursitename.com/wp-admin/maint/repair.php, replacing “yoursitename” with your website’s actual domain. This will bring up the database repair tool.
Click on Repair Database and let it do its thing. You can choose Repair and Optimize Databaseif you like, but it takes considerably longer. Either way, when the tool is finished, load your website again and check for the error. If it’s gone, then you’ll know a corrupted database was the cause.
However, if you’re still seeing the error message, head to the next step. Before you do, make sure to head back into wp-config.phpand delete the code you added to turn on the tool. If you leave it there, someone with ill intentions could gain access to your site easily.
Step 4: Check if Your Database Server Is Down
If all the above steps have failed, one final possibility is that your database server has gone down. At this point, it’s a good idea to verify with your hosting provider that everything is working correctly.
There are a number of reasons why your database host or server might be experiencing issues:
- Too many simultaneous connections to the database.Some providers have limits on how many connections a server can have at one time.
- Problems with another site on your shared hosting server.If you’re on a shared hosting plan, you’re splitting resources with other sites. If one of them has problems, it can spill over to your site. This is one of the reasons dedicated or managed WordPress hosting plans can be beneficial.
- Hardware troubles. Hardware eventually fails, and it’s possible that the server your database is stored on has done just that. Ideally, your host will have redundancies in place so that if one server goes down, there’s another copy of your data available, but this isn’t always the case — especially if you’re hosting your own database on a home or office server.
Your best bet here is to reach out to your web host and inquire about outages or other known issues. If there are none, you can report your problem and ask the support staff to look into it for you.
At DreamHost, you can always find your support options by clicking on the Support button in the top right corner of your control panel:
DreamHost offers 24/7 support, so you can get help any time you need it.
Additional Tips and Solutions That Have Worked for Other Users
If you’ve tried all of the above tips and you’re stillhaving trouble with the Error Establishing a Database Connection, there are a couple of other options that have worked for some users. You can try these either before or after going through the troubleshooting steps above:
- Update your WordPress site URL. If you’ve recently moved your WordPress installation for any reason (such as moving to a new domain nameor migrating to HTTPS), you may need to update your site URL in the database. You can find full instructions for doing so in our knowledge base.
- Reboot your web server. This one might seem a little basic, but sometimes the simplest solutions are the most effective. If you host your database on your own server, try turning it off and back on. Computers are complex, and a simple reboot can fix all manner of odd problems you may be experiencing.
- Ask for help. If you’re not comfortable doing your own troubleshooting, or you’ve tried everything and still can’t get rid of the Error Establishing a Database Connection message, there’s no shame in reaching out for help. You can get in touch with DreamHost support 24/7 by clicking the Supportbutton in your DreamHost panel. You can also try searching on help forums such as Stack Exchangeor Quora. Your question may have already been answered on one of these sites. If not, you can always ask.
At this point, you’ve hopefully resolved the issue and gotten your site back up and running.
Get Content Delivered Straight to Your Inbox
Subscribe to our blog and receive great content just like this delivered straight to your inbox.
Further Reading
Want to learn more about fixing common WordPress errors? We’ve got you covered!
- How to Fix the 500 Internal Server Error in WordPress
- How to Fix Syntax Errors in WordPress
- How to Fix the WordPress Not Sending Email Issue
Ready to Fix a Database Connection Issue?
If you’ve gone to check on your website and found yourself greeted by the Error Establishing a Database Connection message, you’re not alone. It’s a common errorwith relatively simple fixes, so getting your site up and running again shouldn’t be too difficult.
You should follow these steps to troubleshoot a database connection error:
- Check your WordPress database credentials.
- Check your database host information.
- Repair your WordPress database.
- Check if your database server is down.
If you’d rather not have to deal with these types of problems in the future, consider upgrading to DreamPress, our managed WordPress hosting service. Then you can leave the troubleshooting to us!
FAQs
How do I fix error establishing database connection in WordPress Godaddy? ›
WordPress uses connection strings to know which database to connect to. When your site is not connected to your database, it displays the Error establishing a database connection notification. To resolve this error, update the connection strings on your WordPress site.
What does it mean when it says error establishing a database connection? ›This error means that your website files (on the webserver) are not able to connect to your database (on the database server). This article lists some common reasons this error could display on your site, including: Incorrect database credentials in your config file. The hostname isn't working.
How do I get rid of error establishing a database connection? ›- Inspect the wp-config.php File of your WordPress website.
- Check if the Database User has the Correct Privileges.
- Repair the Database.
- Inspect the WordPress Site URL in the Database.
- Restore a Backup of the Site.
- Contact the Web Hosting Provider.
- Configure firewalls to work with SQL Server. ...
- Test connections to SQL Server by using Universal Data Link (UDL) files. ...
- Use PortQryUI tool with SQL Server. ...
- Check whether SQL Server is listening on dynamic or static ports.
PhpMyAdmin also allows you to easily import your WordPress database. Simply launch phpMyAdmin and then select your WordPress database. Next, you need to click on the 'Import' link from the top menu. On the next screen, click on the Choose file button and then select your database backup file you downloaded earlier.
How do I reset my WordPress database? ›- Install and activate the WP Reset plugin. ...
- Go to Tools > WP Reset.
- Scroll down to the Site Reset section.
- Type “'reset” in the Confirmation field.
- Click the Reset Site button.
- A popup message will appear asking you to confirm that you want to reset your site.
Click on the Hosting on the top menu and then cPanel on the submenu. Find the Files section and click on File Manager. You may get a popup asking you to select the directory you want to start in. Choose the Document Root for option and select the website you want to get the database information for.
How do I resolve a WordPress error? ›Getting started with WordPress error troubleshooting
You can start by clearing your cache. A cache helps your browsers load sites faster by storing data. Clearing it helps you get rid of outdated content, which may be enough to fix your issue. You should also consider updating your theme, plugins, and WordPress core.
Manually Fixing Mixed Content Errors in WordPress
First, you need to go to Settings » General and make sure that the 'WordPress Address' and 'Site Address' options have HTTPS URLs. If you see URLs starting with 'http', then you need to go ahead and change them to 'https'.
Here are some reasons the Can't connect to local MySQL server error might occur: mysqld is not running on the local host. Check your operating system's process list to ensure the mysqld process is present. You're running a MySQL server on Windows with many TCP/IP connections to it.
How do I get rid of a connection error? ›
- Reload the page. ...
- Consider if you're using public Wi-Fi. ...
- Check your computer's date and time. ...
- Go incognito. ...
- Clear Your browsing data. ...
- Check your antivirus software. ...
- Update your operating system. ...
- Restart your computer.
- Click the Connections tab .
- Click New connection and choose Database from the menu. The New connection window appears.
- Choose the database type you want to connect to. ...
- Provide the connection properties for your database. ...
- Click Add.
The error "Error establishing a database connection" might occur for the following reasons: There are corrupted database tables. The remote database connection is disabled. The database service is down.
What is the database name in WordPress? ›WordPress uses a database management system called MySQL, which is open source software.
What is error establishing a database connection WordPress HostGator? ›Database Connection Error
If you get an error message that states, “Error establishing a database connection,” then this means that your site has experienced an issue when it tried to make a connection to the WordPress database. When you're experiencing this error, it could have to do with your wp-config. php file.
To test the connection to your database, run the telnet hostname port on your Looker server. For example, if you are running MySQL on the default port and your database name is mydb, the command would be telnet mydb 3306 . If the connection is working, you will see something similar to this: Trying 10.10.
What are the causes of database failure? ›There are many reasons that can cause database failures such as network failure, system crash, natural disasters, carelessness, sabotage(corrupting the data intentionally), software errors, etc.
How do I find database connection settings? ›...
This information includes the:
- Database Host.
- Database Port.
- Database Name.
- Database User.
- Database Password.
- Database Version.
- Database Storage Engine.
Error establishing a database connection This either means that the username and password information in your wp-config. php file is incorrect or we can't contact the database server at localhost:3306. This could mean your host's database server is down.
How do I connect my database to my website? ›- Create the Virtual Machine.
- Install the MySQL Database.
- Prepare the MySQL Database.
- Replace the Static Website.
- Connect the Website to the Database.
- Select the Records in the Database.
- Insert a Record into the Database.
- Update a Record in the Database.
How do I restore my WordPress site without a database? ›
- Search for your website or page on Google's or Bing's results page. ...
- Click on the arrow. ...
- Since we need a cached copy of your website, click on Cache option.
- Restore your website, pages or content, or whatever you need from this cached copy.
- Navigate to the root directory of your WordPress site. ...
- Next, check for WordPress core updates. ...
- Update WP version by typing in wp core update . ...
- In case you need to update the database as well, you can run the following command: wp core update-db .
- And that's it!
- Step 1 - Open File Manager. Log into the one.com control panel. ...
- Step 2 - Open wp-config. php. ...
- Step 3 - Locate the login details. Usually, you can find the login details around line 20 in the wp-config file. ...
- Step 4 - Update details.
If you are experiencing problems displaying WordPress.com pages, clearing the browser cache is a good first step to try to resolve the issue. Some situations where you can find it very useful to clear your browser cache: When the page or post editor is not loading or it fails to load.
What is a common issue with WordPress? ›The WordPress internal server error is often the most common WordPress issue and the most confusing too. This error message typically shows up when something is wrong, but the server doesn't know where the problem is.
How do I check my WordPress site issues? ›Just log in to the hosting dashboard, then go to Sites > Tools > WordPress debugging and click Enable. You can then look around your site to find the cause of the issue or check the log.
How do I get rid of SSL certificate error? ›- Adjust your local time and date settings (check the Google Chrome section above for instructions).
- Clear your browser's cache and cookies.
- Clear your OS's SSL slate or delete any local certificates for Gmail.
- Diagnose the problem with an online tool.
- Install an intermediate certificate on your web server.
- Generate a new Certificate Signing Request.
- Upgrade to a dedicated IP address.
- Get a wildcard SSL certificate.
- Change all URLS to HTTPS.
- Renew your SSL certificate.
...
Here's how to do it:
- Generate a new CSR.
- Activate your SSL certificate.
- Validate your SSL renewal.
- Install and renew your SSL certificate.
- Create Database.
- Create a Folder in htdocs.
- Create Database Connection File In PHP.
- Create new php file to check your database connection.
- Run it.
How do I establish a connection in MySQL? ›
- In the Server name box, enter the MySQL server name. In the Server port box, enter the port number to be 3306. It is the default port.
- In the User name box, enter a MySQL account that has the necessary permissions.
- In the Password box, enter the password for the specified user name.
- Locate the MySQL Command-Line Client. ...
- Run the client. ...
- Enter your password. ...
- Get a list of databases. ...
- Create a database. ...
- Select the database you want to use. ...
- Create a table and insert data. ...
- Finish working with the MySQL Command-Line Client.
Summary. If you run into the “ERR_CONNECTION_RESET” error, it means that your browser can't establish a connection to the remote server. In most cases, it's due to a misconfiguration in your internet settings or something else that's blocking the connection.
What can cause the error message your connection is not secure? ›This error is caused by an issue with the website's SSL certificate – it's missing, or it's expired, or it wasn't issued by a legitimate certificate authority, or the client can't access it for some other reason. SSL certificates are necessary for serving websites over secure HTTPS connections.
Do you need MySQL for WordPress? ›MySQL uses Structured Query Language (SQL), a popular language for databases. MySQL works best with other open-source applications like WordPress, Apache web server, the Linux operating system and PHP. Before you can install the WordPress software, you first need to have a MySQL database.
How do I update my WordPress database in MySQL? ›- Step 1: Create a new 5. ...
- Step 2: Create a dump of your old database. ...
- Step 3: Import the old database content into the new database. ...
- Step 3b: I'm getting a SQL error! ...
- Step 4: Setting up WordPress to talk to the new database. ...
- Step 5: Upgrade WordPress through FTP. ...
- Step 6: Logging in for the first time.
WordPress uses MySQL as its management system. MySQL uses the Structured Query Language to create, read, update, and delete data from a database. While most MySQL queries run automatically, users can also perform them manually to change WordPress URLs and carry out other tasks.
How do I make my database active? ›Database administrators can use the ACTIVATE DATABASE command to start the selected databases. This eliminates any application time spent on database initialization. The ACTIVATE DATABASE command is the only way to explicitly activate a database.
How to connect database to server? ›Connect to a SQL Server instance
Start SQL Server Management Studio. The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine. For Server type, select Database Engine (usually the default option).
Database connection files
When you create the connection in the Catalog tree, the file is created in \\<computer_name>\Users\<user_name>\AppData\Roaming\ESRI\Desktop<release#>\ArcCatalog, but you can move the connection file to another location.
Why is my WordPress not installing? ›
The major causes of installation problems are: incorrect editing of the wp-config file database details. uploading WordPress to the wrong location on your server. using a web server that doesn't support standard WordPress hosting requirements.
How do I fix error establishing a database connection on WordPress on Digitalocean? ›- Why Does WordPress Database Error Occur?
- Determine Error Establishing a Database Connection.
- Check Database Login Credentials in wp-config.
- Reset Username and Password.
- Database Host Value.
There are 4 main types of errors on WordPress: HTTP, PHP, MySQL and JavaScript errors. These errors can be due to an incompatibility between plugins, a corrupted file, a server or memory problem, etc. Some of the famous errors include the 500 error, White Screen of Death and database connection error.
How do I resolve a WordPress issue? ›- Research Your Error Message. ...
- Create a Complete Backup of Your WordPress Site. ...
- Clear Browser Cache. ...
- Clear Your WordPress Cache. ...
- Deactivate All Plugins Installed on Your Website. ...
- Switch to a Default WordPress Theme. ...
- Refresh Permalinks.
First, you need to launch the phpMyAdmin from your hosting account's cPanel dashboard. After that, you need to select your WordPress database. PhpMyAdmin will show your WordPress database tables. You need to click on the 'Browse' link next to wp_users table.
How do I fill the database connection details in WordPress? ›- Step 1 - Open File Manager. Log into the one.com control panel. ...
- Step 2 - Open wp-config. php. ...
- Step 3 - Locate the login details. Usually, you can find the login details around line 20 in the wp-config file. ...
- Step 4 - Update details.
You can confirm this information from your WordPress hosting account dashboard. Simply log in to your hosting account and click on MySQL databases under the database section.
How do I restore my WordPress database? ›To get started, open your WordPress dashboard and select Settings > UpdraftPlus Backups from the menu. Then, under the Backup / Restore tab, scroll down to Existing Backups. Here you will find the most recent backups of your website. Select the backup you would like to use, and then click on the Restore button.
How do I manually clean my WordPress database? ›- Reduce the number of saved revisions. By default, WordPress saves revisions of your posts and pages. ...
- Prevent spam comments. ...
- Regularly empty your WordPress trash. ...
- Delete unused plugins and themes. ...
- Disable pingbacks and trackbacks. ...
- Delete unused media files.