0

I'm desperate for help. I have spent almost a day now trying to figure out why cURL is suddently throwing curl: (7) Failed to connect to magento.localhost port 80: Connection refused on local vhosts after I restarted macOS High Sierra.

My setup worked without problems before – ping still works, opening the domain in the browser also works as expected. What is going on??

ping magento.localhost

PING magento.localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.034 ms

host magento.localhost

magento.localhost has address 127.0.0.1
magento.localhost has IPv6 address ::1

scutil -r magento.localhost

Reachable

apachectl configtest

Syntax OK

netstat -a | grep http | grep LISTEN

tcp46 0 0 *.http . LISTEN

curl -v magento.localhost

Rebuilt URL to: magento.localhost/
Trying 127.0.0.1...
TCP_NODELAY set
Connection failed
connect to 127.0.0.1 port 80 failed: Connection refused
Failed to connect to magento.localhost port 80: Connection refused
Closing connection 0
curl: (7) Failed to connect to magento.localhost port 80: Connection refused

I have tried every suggestions I found! - thank you so much for your help!

David Hirtz
  • 123
  • 8
  • 1
    Try `telnet magento.localhost 80` to confirm you can connect. Do this on the same system you run `curl`. You could also try via IP, `curl -v `. – Nic3500 Sep 13 '18 at 11:31
  • Thank you very much! I [figured it out](https://stackoverflow.com/a/52313323/1686394) with your help! :) – David Hirtz Sep 13 '18 at 12:02

1 Answers1

0

Nic3500, you saved my life! After your comment I found out that my vhosts produced different results than localhost itself.

telnet magento.localhost 80

Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection
refused telnet: Unable to connect to remote host

telnet localhost 80

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

So I have changed /usr/local/etc/dnsmasq.conf to address=/localhost/::1 and /private/etc/resolver/localhost to nameserver ::1 and now cURL is working alongside with everything else.

Thank you very much!

David Hirtz
  • 123
  • 8