0

I have an apache web server running on my mac. Since upgrading to macOS High Sierra, if I connect to localhost or 10.0.0.7 in Safari (or any other web browser) I get the message "Safari can't open the page "localhost" because Safari can't connect to the server "localhost".

I can confirm apache is running. If I run apachectl configtest I get "Syntax OK".

If I type httpd -v I get

Server version: Apache/2.4.28 (Unix)
Server built:   Oct 19 2017 09:26:34

I have tried restarting apache and this has no effect. Does anyone have any idea how I can get it working? All my web files are stored in /Library/WebServer/Documents.

Attached is a copy of my httpd.conf.

4
  • Is this version of Apache installed via homebrew, macports, or the like? The version I have is 2.4.27, which should be the same for everyone. Oct 22, 2017 at 11:47
  • What happens if you try to ping both localhost and 10.0.0.7?
    – Allan
    Oct 22, 2017 at 18:22
  • It is the version of apache installed from Homebrew. Oct 23, 2017 at 17:27
  • If I ping 10.0.0.7 I get ping 10.0.0.7 PING 10.0.0.7 (10.0.0.7): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 Request timeout for icmp_seq 3 Request timeout for icmp_seq 4 Request timeout for icmp_seq 5 Oct 23, 2017 at 17:27

1 Answer 1

1

Take a look at your hosts file, you should have entries in there for your localhost and local configuration. The hosts file is in /etc, so the best way to open it is by using Terminal and this (read-only) command:

open -a TextEdit /etc/hosts

You should see an one or all of these for localhost there like:

127.0.0.1   localhost   
::1         localhost
fe80::1%lo0 localhost

127.0.0.1 is your machine (aka localhost).

You can add other IP addresses from your local network to route domain names to a local development folder to the hosts file. For example, mine has custom entries from old projects like:

10.0.10.111     teambox.dongguk.ac.kr

To make changes to the hosts file, you'll need to use:

sudo open -a TextEdit /etc/hosts

Enter your user account password when prompted.

Here is a full article on making edits to your hosts file: The Mac Hosts File: How to Modify /etc/hosts in OS X with TextEdit

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .