localhost refused to connect - MAMP Pro - apache

There seem to be a few questions that are similar but could not find the answer.
An hour ago (and the months before that :-)) everything was working fine. It looks like after updating to XCode 9.2 things stopped working.
I've justed updated to MacOS High Sierra 10.13.2 as there were some Apache updates included, but it didn't solve the issue. Maybe the XCode update changed something to the httpd.conf file? I'm not too familiar with the settings in there, so I'm unable to determine if something changed in that file.
Error in Chrome:
This site can’t be reached
www.example.dev refused to connect.
ERR_CONNECTION_REFUSED
My setup:
MacOS High Sierra 10.13.2
MAMP Pro 4.2 (latest version)
Ports are Apache: 80 and MySQL: 3306
VPN is off
If I run sudo nano /private/etc/hosts it has the following entries (I run my local website on www.example.dev)
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.example.dev # Note; I added this myself a long time ago as else the URL including www doesn't work
127.0.0.1 example.dev # MAMP PRO - Do NOT remove this entry!
::1 example.dev # MAMP PRO - Do NOT remove this entry!
What I tried:
Changing ports to default MAMP ports (Apache: 8888 and MySQL: 8889). No luck
If I run apachectl configtest in terminal it returns Syntax OK
UPDATE
Just saw that if MAMP Pro is off:
It still gives the same error in Chrome
It still returns Syntax OK with apachectl configtest
When I run sudo apachectl stop it returns /System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
UPDATE 2
Out of frustration I downloaded Firefox to check and... all my local dev sites work there! In Chrome I still get the same error, even after clearing browsing data.

Turns out, Chrome (and Safari as well) were redirecting to https, so https://www.example.dev. And the problem was the .dev TLD.
If you run into the same problem (force forward by Chrome to https) and:
You DON'T use .dev, read this post for possible solutions
You DO use .dev as your local TLD, you need to change it to something else. Chrome redirects .dev TLDs to https since version 63. See this article and your best alternative TLDs here.

Related

Disable SSL on localhost using MAMP

Month ago I've installed MAMP (not PRO) and I set SSL for localhost following this tutorial. It works perfectly by the way:
https://torbjornzetterlund.com/how-to-get-ssl-working-on-mamp-for-os-x/
Today I removed MAMP and install it again, but I can't access localhost with http://localhost, it redirects to https:// and connection is not allowed.
The apache config is the default config.
How can I remove/disable the openSSL I set?
I tried solutions mentioned here without success
Wordpress always redirects to https after copying to localhost
But the only thing that worked was to change default MAMP ports under MAMP > Preferences
I ran into a similar issue. I set up a local host SSL environment for the one site as required to develop with the Facebook Api and instagram api.
When I went to update the site to a fresh directory with the newest version in production, it would fail because the SSL is not setup for the new directory yet. Redirecting me to https://www.localhost.
My solution was to backtrack using documentation on how to enable SSL on the site. What I found is this:
This is tested on MAMP Free version, possibly works on PRO but untested.
The instructions state:
Open /Applications/MAMP/conf/apache/httpd.conf and uncomment Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf.
So I navigated to that directory, opened the httpd-ssl.conf file in my text editor and located the uncommented line, commented this line using "#" and save. Doing this resulted in disabling the ssl behavior and retains all my previous configuration.
When your ready to go back to SSL, uncomment that line and make sure you have reconfigured your ssl to the new directory(Github below explains how to configure for ssl). Here is the github I reference for the work. Good luck!
https://gist.github.com/jfloff/5138826
Line #3
I am using MAMP Free version and accidentally launched the PRO version.
It changed ports for the Free version too... So suddenly localhost and other virtual hosts changed to SSL.
Reseting ports in the Free Version with the button "Set Web & MySQL ports to 80 & 3306" worked for me.

localhost:8888 to localhost MAMP PRO mac [duplicate]

I have both apache and mySQL running with the default MAMP ports (8888 and 8889 respectively) and everything seems to work, but when I switch the ports to 80 for Apache and 3306 for mySQL, the mySQL server is unable to restart.
I am trying to setup MAMP to run on these ports because apparently this is optimal for developing in dreamweaver... Thus, given that I would like to have the ideal dev environment for dreamweaver, is there a way around using the 3306 port? Or, what could the potential problems be?
Thanks
Just in case anyone is having the same problem, here is how I fixed it:
I opened the Activity Monitor program and selected "All Processes"
Next I search for "mysqld" in the search text field. There is a good chance that you have an instance of mysql running and you have to find it and hit quit process.
Restart MAMP and you should be all set.
i posted my solution here..
but will it annoy the editor gods to re-post? i found this works so clearly and consistently that it's worth evangelizing.
fix courtesy of Abhinav Sood.
Launch MAMP. Open Terminal by typing terminal into Spotlight (Command + Space).
Open MAMP Preferences (Command + , ) and click on Reset MAMP Ports
(Port 8888 and Port 8889 for Apache and MySQL respectively).
Click on OK.
Switch to the terminal. Type sudo apachectl stop to shutdown the system Apache.
Restart MAMP.
Open MAMP Preferences once again and click on Set to Default Apache and MySQL ports. This will set the Apache and MySQL ports to 80 and 3306 respectively.
Switch to the terminal. Type sudo apachectl restart to restart Apache.
Switch back to MAMP and click on Open Start Page (or go to http://localhost/MAMP/?language=English in your browser)
And you’re done.
I configured httpd.conf.
In that file just replace:
Listen 80
for
Listen localhost:80
restart mamp. It worked for me.
#Mazal
Finally I found your great great solution of fixing this localhost:80 and apachectl issue. However, the issue will resume back when after re-start against!!!!!!
So fix this goto perference-->when quiting MAMP--> [uncheck] the box stop server.
this will keep the port setting to localhost:80 and apachectl in green light.
cheers!

WAMP localhost redirects to my IP

I had to recently wipe my PC and I'm setting up my development environment again using WAMP.
After installing WAMP, if I visit http://localhost instead of seeing the WAMP homepage I get redirected to http://x.x.x.x, where x.x.x.x is my IP.
I had this issue on another PC and after setting the inbound rules for Apache HTTP Server in my Windows Firewall settings to allow all domains it fixed the issue. I applied this to my PC, and the issue does not seem to be present for Internet Explorer, whereas for Chrome and Firefox the localhost to my IP redirect issue persists even after clearing the cache for each browser.
My C:\Windows\System32\drivers\etc\hosts file looks like this:
127.0.0.1 localhost
::1 localhost
and my firewall rules look like this:
I am not currently using vhosts and I'm on a network at my workplace (if that has any implications?)
I also encountered the same issue when using Laragon which uses vhosts and whenever I visited a virtual host, e.g. mysite.dev it didn't work properly either.
My question on the Laragon forum: https://forum.laragon.org/topic/126/accessing-mysite-dev-redirects-to-url-which-shows-index-php-at-root-folder/3
The Problem
I'm behind a proxy which is used for browsing the web at my workplace. The proxy seemed to be messing up the dns resolution whenever I made a call to localhost (when using wamp) or one of my vhosts (when using Laragon).
This was clear as when I ran the following from the command line: ping site.dev I was getting the expected response from 127.0.0.1. However, when going to site.dev in my browser I was getting redirected to my IP, so essentially my etc/hosts file was being ignored for dns resolution.
The difference between the two being that the browser is using the proxy whereas the command line isn't!
The Solution
After trying many different solutions which seemed to work for localhost (on wamp) only, but not vhosts (on Laragon) I finally got to the solution which was actually so simple!
So, for chrome I simply went to chrome://settings/ > Network - Change proxy settings > LAN Settings > Proxy Server - Advanced
Then in the Exceptions text box I added the following:
*.dev;localhost;127.0.0.1
Here's a screenshot of my settings from Chrome/Internet Options
And that did the trick! Hope this can help someone else.

Unable to connect to localhost Apache Ubuntu

I run xampp (apache) on Ubuntu 12.04. I've got localhost declared as ServerName localhost in httpd.conf. So far, I've not experienced problems with this but now, the browser Firefox is unable to connect to localhost. What could the problem be? Thanks.
OK. Found the answer and responding to myself in case it could be of interest to others; Actually, Apache server was not running. When I started xampp, it said Apache is already running but in fact wasn't due to the fact that the file logs/http.pid was corrupt. I deleted this file and then restarted xampp. This time it did launch the apache server and everything is fine.

Local site not running under MAMP after Yosemite upgrade

I just upgraded to Yosemite and noticing problems with MAMP. I was running Piwik locally (port 7788) before the upgrade, and it worked perfectly. Now, however, when I start MAMP I just get a 500 Internal Server Error.
Some searching around suggested that one issue was that MAMP was using Port 8888 for Apache and 8889 for MySQL, whereas they should now be changed to Port 80 and 3306 respectively (the default ones for those apps). This didn't change anything for me though.
I also read it could be an issue around PHP and a suggestion was to go to \etc\apache2\httpd.conf and uncomment the line LoadModule php5_module libexec/apache2/libphp5.so, again this did nothing.
I don't know enough about Apache2/MySQL/PHP to trawl through them and figure anything out so I'm hoping someone here can suggest how I go about correcting this.
MAMP will use it's own version of Apache2 so you will need to change the settings/ uncomment the modules in that httpd.conf file.
/etc/apache2/ is the default server preinstalled on the machine, which is different to MAMP's
Try looking for it here: Applications ▸ MAMP ▸ conf ▸ apache