This question already has answers here :
What causes the ‘Connection Refused’ message?
( 2 answers )
close

6 years ago

.
I have Apache 2.4 running on Mac OS X. apachectl configtest give me : Syntax OK .
I have two virtual hosts set up, one called localhost, one called test.dev .


    DocumentRoot "/Users/psychomachine/Development/_localhost"
    ServerName localhost
    ServerAlias www.localhost
    
        Require all granted
    


DocumentRoot “/Users/psychomachine/Development/test”
ServerName test.dev
ServerAlias www.test.dev

Require all granted

localhost equitable works :

↪ curl -I -L localhost                                                                                                                                                              15:51:08
HTTP/1.1 200 OK
Date: Tue, 08 Dec 2015 14:51:17 GMT
Server: Apache/2.4.16 (Unix)
Last-Modified: Tue, 08 Dec 2015 08:52:04 GMT
ETag: "c-5265f1673f500"
Accept-Ranges: bytes
Content-Length: 12
Content-Type: text/html

whereas test.dev does n’t :

↪ curl -I -L test.dev                                                                                                                                                               15:51:01
curl: (7) Failed to connect to test.dev port 80: Connection refused

My hosts file has an entry for test.dev, which is why I can ping test.dev and hear back from 127.0.0.1 .

↪ ping test.dev                                                                                                                                                                     15:53:39
PING test.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.069 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.096 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.111 ms
^C
--- test.dev ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.069/0.092/0.111/0.017 ms

I ‘ve spent hours looking at this, but I still do n’t understand how it is possible to ping test.dev but distillery get connection refused. Apache is listening on interface 80, and I am not getting a page forbid kind of error. There is nothing in Apache logs for test.dev, because the request for test.dev never makes it to Apache .
I am missing a crucial element of the puzzle — and I hope person will be able to point me in the right direction .
many thanks in advance.

Edit: As I said, Apache is listening on 80 :

sudo lsof -i ':80'                                                                                                                                                                16:54:46
COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd   2464   root    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)
httpd   2466 daemon    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)
httpd   2467 daemon    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)
httpd   2468 daemon    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)
httpd   2469 daemon    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)
httpd   2470 daemon    5u  IPv6 0x8883a2a43af0ca7f      0t0  TCP *:http (LISTEN)

Additional info

scutil -r test.dev                                                    08:25:59
Reachable 

telnet test.dev                                                       08:26:17
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

telnet test.dev 80                                                    08:26:43
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

127.0.0.1 test.dev is in /etc/hosts and Listen *:80 is in apache ‘s conf .

informant : https://themedipia.com
Category : Website hosting

Leave a Reply

Your email address will not be published.