Firstly I've read many tutorials, I'm trying for many hours during last days (because I know there were billion similar questions and tutorials for the same thing before) but I'm in the ends... :-(

The last site I've followed (and checked many times) was https://tech-cookbook.com/2020/11/14/setting-up-your-local-web-server-on-macos-big-sur-11-0-1-2020-mamp-macos-apache-mysql-php/. Before I've tried https://medium.com/nerd-for-tech/how-to-run-apache-php-on-mac-os-big-sur-7ffbf7cbef7b, but they looks very similar.

What I have

  • Apache 2.4.46 (apachectl -v)

  • php 7.3.24 (php -v)

  • Apache should be setted correctly. Stopped and started.

  • sudo apachectl configtest returns Syntax OK

  • in /etc/apache2/httpd.conf I have set DocumentRoot and <Directory ... to /Users/username/Sites/

  • /Users/username/Sites has chmod 777

  • /Users/username/Sites shows me directory content (path is correct)

  • /etc/apache2/extra/httpd-vhosts.conf is set to (source https://wpbeaches.com/set-up-virtual-hosts-on-macos-big-sur-11-in-apache/)

      <VirtualHost *:80>
          ServerName localhost
          DocumentRoot /Users/username/Sites/ 
          # I've tried: 
          ## insert value into "",
          ## localhost, 
          ## localhost/~username, 
          ## set localhost and ServerAlias to localhost/~username, etc.

As result, both http://localhost and http://localhost/~username returns me ERR_CONNECTION_REFUSED.

I've checked all .conf files settings with my older macbook and they look very similar in both machines... :-(

Any idea where could be problem? I'm able to put here more additional information (copy conf files content, whatever) if needed... I'm a little bit hopeless... :-(



ps -ax | grep '[h]ttpd' returns

14994 ??         0:00.51 /usr/sbin/httpd -D FOREGROUND
14997 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
15002 ??         0:00.01 /usr/sbin/httpd -D FOREGROUND
15040 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
15042 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND
15043 ??         0:00.00 /usr/sbin/httpd -D FOREGROUND

sudo lsof -a -iTCP -sTCP:LISTEN -c httpd returns

httpd   14994 root    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   14997 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15002 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15040 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15042 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
httpd   15043 _www    4u  IPv6 0xbbfd6axxxxxxxxxx      0t0  TCP *:http (LISTEN)
  • Is Apache actually running? Check with ps -ax | grep '[h]ttpd' (note that if it is running, you'll probably see several processes.) If it's running, check whether it's listening for incoming connections with sudo lsof -a -iTCP -sTCP:LISTEN -c httpd Oct 1, 2021 at 5:02
  • @GordonDavisson thx for your comment. Both outputs are added into the question (sorry, I'm not able to tell if it's running from it)
    – pavel
    Oct 1, 2021 at 10:35
  • The lsof output indicates it's listening for IPv6 connections, but not for IPv4; I don't know what'd cause that, but that's what I'd concentrate on trying to find. Actually, one more test: run netstat -anv | grep '[.]80 .*LISTEN' -- you'll see a line starting with tcp6 showing that it's listening on TCP over IPv4, but does is also show one starting with tcp4? If so, that'd show that something else is grabbing the port on IPv4, and preventing Apache from getting it. Oct 1, 2021 at 17:25
  • @GordonDavisson I'm getting this tcp46 0 0 *.80 *.* LISTEN 131072 131072 18249 0 0x0080 0x0000000e
    – pavel
    Oct 1, 2021 at 17:47
  • @GordonDavisson: _If so, that'd show that something else is grabbing the port on IPv4, and preventing Apache from getting it. _... what does it mean, or what I should to do? I'm totally lost... :-(
    – pavel
    Oct 1, 2021 at 17:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.