I can’t connect to localhost on Mac high Sierra I have followed this guide to set-up Apache on High Sierra: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

I used it to set it up on Sierra.

But when I go to http://localhost I get "Hmm. We’re having trouble finding the site "

A suggestion on this similar question: localhost on macOS High Sierra. Which I've tried, but still cannot connect to localhost:(

I tried install mamp and reinstall it then install ampps but still that problem , I write in terminal sudo apachectl start then sudo apachectl stop and again start but nothing changes.

Please help me i tried to solve problems for 2 weeks ago :(
You need to do some troubleshooting to find out what's wrong. That error message ("Hmm. We’re having trouble finding the site.") sounds like Firefox having trouble looking up the address for the name "localhost", which is really weird because "localhost" is pretty much built into the operating system. So, first verify that "localhost" is being properly resolved with the command dscacheutil -q host -a name localhost -- it should look like this:

$ dscacheutil -q host -a name localhost
name: localhost
ipv6_address: ::1
ipv6_address: fe80:1::1

name: localhost
ip_address: 127.0.0.1


If the response doesn't list at least the addresses "::1" and "127.0.0.1", something is terribly wrong. (It's ok if it lists additional addresses like "fe80:1::1".) This has nothing to do with Apache. If this is the problem, check your /etc/hosts file; it should contain at least this:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 


Also, try bypassing the name lookup by trying to reach "http://127.0.0.1/" and "http://[::1]/". If those work, Apache is running and "localhost" lookup is the reason you're getting errors.

If bypassing the name lookup doesn't work, check to see whether Apache ("httpd") is running with the command ps -ax | grep '[h]ttpd'

$ ps -ax | grep '[h]ttpd'
48917 ??         0:00.62 /usr/sbin/httpd -D FOREGROUND
48924 ??         0:00.02 /usr/sbin/httpd -D FOREGROUND
48927 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND


If there are no "httpd" processes listed, Apache is not running, and you'll need to troubleshoot further to find out whether it's not starting at all, or starting and getting a fatal error. If it is running, make sure it's listening for network connections with sudo lsof -a -c httpd -i -sTCP:LISTEN

$ sudo lsof -a -c httpd -i -sTCP:LISTEN
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd   48917 root    4u  IPv6 0x3c39418bc7b0ab99      0t0  TCP *:http (LISTEN)
httpd   48924 _www    4u  IPv6 0x3c39418bc7b0ab99      0t0  TCP *:http (LISTEN)
httpd   48927 _www    4u  IPv6 0x3c39418bc7b0ab99      0t0  TCP *:http (LISTEN)


In the above, all three "httpd" processes are listening for TCP connections on "*:http" -- that is, port 80 (http) on all of this computer's IP addresses. If it lists something else, Apache is running, but the configuration is weird.

Note: none of the above will solve the problem, it's all directed toward finding out what the actual problem is. Once you have a better idea what the problem is, then you can try to figure out how to fix it.