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

Development Tools

Lydia Esterline
Lydia Esterline
9,581 Points

Localhost issue

Yesterday, I worked through the wordpress and bootstrap track. I built my site successfully using dreamweaver, mamp and localhost. Towards the end of hours of work everything seemed to go wrong.

Mamp pulls up the open start page with no problem. I can see my database through phpmyadmin however, when I navigate to localhost to view the site itself it returns an error. "Safari/Chrome" Can't connect to server. Can't open page "localhost/phpmyadmin/" because Safari/Chrome can't connect to the server localhost.

I'm not sure how or why things went wrong. I seemed to have lost localhost. I no longer see the site development folder in the user directory on my mac. (running Yosemite)

Also I tried changing the ports to 80 in mamp but it also gives me an error.

MAMP has been upgraded and there is a message saying a new version of phpmyadmin is available but, I can't even begin to figure out how to update phpmyadmin until I figure out how to fix the localhost.

I've spent half the night with this, my brain is toast. Any ideas what to do?

Also tried to restart apache with the sudo apachect1 restart but it's telling me that apachect1 command not found

update.. also tried changing the envvars to _envvars, now I'm getting an error on that two "another program is using it"

17 Answers

texas2010
texas2010
26,901 Points

Weird, Because I could use localhost:8888 on safari and chrome. ofc stupid build-in Apache from mac is run. i did turn it off but i cant change to localhost:80. So i give up with that. but as long my mamp is still work for me. Oh well.

Lydia Esterline
Lydia Esterline
9,581 Points

It's just strange. MAMP works but not for my development server

Matt Trask
Matt Trask
10,027 Points

Did you try localhost:8888/ or localhost:8000/ ?

Lydia Esterline
Lydia Esterline
9,581 Points

yes to both

As far as I can tell there was no reason to stop working it just did from one moment to the next

Philip Benton
Philip Benton
1,378 Points

Where did you run the sudo command to try restarting Apache? With MAMP you start/stop both Apache & MySQL via the MAMP interface.

Try and reset the MAMP ports by clicking "Set default MAMP ports" then visit http://localhost:8888

Lydia Esterline
Lydia Esterline
9,581 Points

I tried to run the sudo command in the terminal as per

http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

but I'm not very knowledgeable in this so I did not go past the restart. I have MAMP and have defaulted, start/stop server, reset, done everything I can think of and I still get the "can not connect to localhost"

tried everything. I did have a backup of my database from my wordpress/bootstrap work and tried uploading it (after deleting the old one) now it's telling me that no database selected.

In the weird section.. when I type in http://localhost:8889 nothing happens on the page but a file "unknown" automatically downloads to the download folder.

Philip Benton
Philip Benton
1,378 Points

If you are using MAMP the guide you have linked to will not help. MAMP is self contained software which provides you with MySQL, Apache and PHP so you do not need to install each on your Mac. As far as I know Terminal commands will not interact with MAMP.

When you Start the server within MAMP are there any errors? Does Apache actually start?

Lydia Esterline
Lydia Esterline
9,581 Points

Understood and that's fine. I'm more comfortable figuring this out from MAMP anyway.

Both Apache and MySQL Sever start up, but yes, there is a pop up that says... "Do you want the application "mysql" to accept incoming network connections?

Which did not pop up before. Other than this, the only other error I get with the MAMP control panel is trying to change the ports if I click 'Set Web & MySQL ports to 80 & 3306 it tells me it's in use" so I just clicked it back to default

Philip Benton
Philip Benton
1,378 Points

Once the server has started are you able to access http://localhost:8888/MAMP/ to view the default start page?

Lydia Esterline
Lydia Esterline
9,581 Points

yes, oddly enough that's never been the problem.

Philip Benton
Philip Benton
1,378 Points

Ok, so the server is working then.

Now, when you just open http://localhost:8888 what is the error message you now have?

Lydia Esterline
Lydia Esterline
9,581 Points

Safari Can't Connect to the Server Safari can't open the page "localhost" because Safari can't connect to the server "localhost".

Philip Benton
Philip Benton
1,378 Points

What are you typing in your browser address bar, I presume from that you are typing localhost or http://localhost.

You need to include the port number (8888, MAMP default) like this: http://localhost:8888

Lydia Esterline
Lydia Esterline
9,581 Points

yes, exactly that and I'm still getting the same "can not connect to server". I'm thinking might try uninstalling mamp and see if that does anything interesting

Philip Benton
Philip Benton
1,378 Points

Let's just look at one last thing - Have you set the Document Root correctly within MAMP to point to your WordPress directory?

Philip Benton
Philip Benton
1,378 Points

Ok, I can only think there is a port conflict. Try changing the Apache Port only to something like 9999, click ok and Stop/Start the Servers again.

Now visit http://localhost:9999 in your browser.

Philip Benton
Philip Benton
1,378 Points

Very difficult to diagnose without being able to see it. Try reinstalling MAMP but ensure you uninstall first. Also make sure you have your database backed up.

Lydia Esterline
Lydia Esterline
9,581 Points

It's absolutly confounding. MAMP has been installed and uninstalled. I even set up a new wordpress directory to see if maybe that would work. so far nothing. localhost isn't even telling me it can't find the directory or database it simply can not find the localhost period. I'm wondering if Yosemite has a bug in it?

I'm at such a loss. Thank you for your help, though.

Matt Trask
Matt Trask
10,027 Points

If you want, one of us could hope on teamview or gotomeeting and see whats happening. Can you take screen shots of the process for us?

Lydia Esterline
Lydia Esterline
9,581 Points

I just created a new database (for the third time) and all seemed to go well but when trying to create a user I'm getting a

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server version for the right syntax to use near

Is this a clue?

Matt Trask
Matt Trask
10,027 Points

Probably not, its just telling you that whatever you typed in, wasnt correct for SQL

Lydia Esterline
Lydia Esterline
9,581 Points

What about a stack overflow ? What does that even mean?

Matt Trask
Matt Trask
10,027 Points

Stack Overflow is the end all be all to developers asking questions. thats a solid place to go to get answers.

Lydia Esterline
Lydia Esterline
9,581 Points

ah okay, I thought it was a possible reason why Chorme is telling me ERR_Connection_Refused (when I googled it)

Lydia Esterline
Lydia Esterline
9,581 Points

Okay, so slight progress. I started to use the MAMP PRO and while if I direct type in localhost:8888 or any variation thereof the browser kicks back the "can't find localhost" If I click the little arrow button next to the field "server name... localhost things "seem" to work. But now I can't access the phpmyadmin because when I click webstart it takes me straight to localhost, which gives me the error.

I'm kinda sorta reaching my limit here. I may have to take out my frustration on an inanimate object somewhere. :P