Seeing the web page message “Error Establishing a Database Connection” is pretty common.
Its a fatal website error that can happen on any type of website that is database driven.
It’s common because the following are not a factor in causing it. Any database driven website can generate this error.
- It’s not due to the type of CMS you are using. So you won’t see a WordPress error establishing a database connection any more than you would see it on a Joomla, Drupal or any other type of open source or commercial content management system software.
- Database connection errors are not specific to your web host. While cheap, low budget, shared hosting service like GoDaddy, Hostgator or Bluehost can be a more common source of this error due to server performance issues, the error can occur on any web host. (This error can be code related or server related)
- If you are using a local server environment with MAMP, XAMPP, WAMP – there could be a configuration error you need to resolve, but it’s not specific to this setup and can be easily fixed.
- This error is not related to your web browser. People will report to me they are seeing an error establishing a database connection in Chrome browser. It has nothing to do with your browser, operating system or device. You can check the webpage in Safari, Firefox, on a desktop, laptop, iPhone… The web page will throw the same error. This is because the error is coming from the web server where the website code resides. It is nothing that you are doing to create or cause this error.
What does Error Establishing a Database connection mean?
It’s literally just what it says. Your website code can not connect – or “talk” to the database. without that connection, any page on the website fails. Typically this means EVERY web page on your site will be down because database driven websites almost always connect to the database on every single page.
So while some errors are quite cryptic, i.e 500 Internal Server Error, this database error gives you a good clue as to what is going on.
How to fix error establishing a database connection?
First you need to determine if it is a code related error or server error. If you don’t know how to do this, contacting your web hosting support is a starting point. If they determine that is is server related, they will fix it if the database server is down. If it is code related though, they should tell you that it is your problem to fix. ( A bit of advice, – NEVER give your web hosting support permission to modify your code. If they do it without asking first, find a new host.)
If they tell you it is code related, the majority of time it is due to incorrect login details. In order to connect your code to a database, you need to tell it:
- database name
- database username
- database password
- database server
This is typically stored in a configuration file. Depending on how your site is coded this could be in different places. For example with WordPress, the database connection is stored in wp-config in your root directory, but any other type of PHP website is not going to have their config file named wp-config.
Other reasons could be a corrupt database, or your host has made upgrades/changes that require code updates.
If you need help troubleshooting this website error, or want to hire me to fix your website, get in touch. I’ve been a web database developer for over 25 years.I’ll have your site back online in no time.