Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Make a Website with WordPress Installing WordPress The Famous 5-Minute WordPress Install

Lindsay Impellizzeri
Lindsay Impellizzeri
3,182 Points

Error establishing a database connection

When I went to my url (/wp-admin), I got this message:

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. This could mean your host's database server is down. Are you sure you have the correct username and password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

Help?

3 Answers

J.T. Gralka
J.T. Gralka
20,126 Points

Hey Lindsay,

It's tough to say what the problem could be. I'm assuming that you're using Wordpress on your webserver or a local machine with Apache, PHP, and MySQL running. My only other guess based off of the little information you provided is that you might have an issue with your wp-config.php file. Make sure that your database url, name, and credentials are set up correctly for the database in the wp-config file. If they aren't you'll probably get that warning.

I realize that most of what I said reiterates what the error message told you, but I would start by making sure that everything is hunky dory with your wp-config.php file. Are you developing locally, or are you running your WP site on a remotely hosted web server? Is there any other information you can tell us about how you've set up your WP instance?

I look forward to your response, and hopefully your issue is resolved soon!

Best wishes,

J.T. Gralka

Lindsay Impellizzeri
Lindsay Impellizzeri
3,182 Points

I fixed it!!! Woo hoo. Thank you for your help. I did some peeping around and realized there was a wp-config.php file as well as a wp-config-sample.php. I deleted the sample because I knew the other one was edited correctly. That fixed it right away. Again, thank you for your response!

J.T. Gralka
J.T. Gralka
20,126 Points

Awesome! Glad to hear you got it working! :)

J.T. Gralka

Elizabeth BABYCH
Elizabeth BABYCH
6,993 Points

Lindsay, I'm having a similar issue you to. Just wondering where you did the 'peeping around' to find the sample and wp-config.php files? Thanks.

Lindsay Impellizzeri
Lindsay Impellizzeri
3,182 Points

Hey Lizzy,

I was looking at the files in FileZilla. There was a wp-config-sample.php that was messing everything up because I also had a wp-config.php file. I'm not sure if it will be the same issue for you, but that's what happened with mine!

Hope this helps. Lindsay