skip to Main Content

I get a apache error when I try access to anything folder or file, it returns Http Not found or Forbidden
I am trying restart and start apache

sudo apachectl restart

output:

(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

I am trying stop it

sudo apachectl stop

output

httpd (no pid file) not running

I run sudo lsof -i:80

output:

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

    httpd    8904 root    5u  IPv6 0x21884d81f1597d8f      0t0  TCP *:http (LISTEN)
    httpd    9012 _www    5u  IPv6 0x21884d81f1597d8f      0t0  TCP *:http (LISTEN)
    httpd   12726 _www    5u  IPv6 0x21884d81f1597d8f      0t0  TCP *:http (LISTEN)
    httpd   12731 _www    5u  IPv6 0x21884d81f1597d8f      0t0  TCP *:http (LISTEN)
    httpd   12732 _www    5u  IPv6 0x21884d81f1597d8f      0t0  TCP *:http (LISTEN)

Any idea to solve that ?

Useful information:

OS X El Capitan

8

Answers


  1. One of a couple of things could be happening:

    1. You have a different version of apache running. You can make sure that you’re using the correct one by running which apachectl. As an example, I also have two versions of apache /usr/sbin/apachectl and /usr/local/bin/apachectl
    2. You’re not running apachectl start as root, although it appears that you are.
    3. You can run sudo lsof -i:80 to see what’s binding that port currently
    Login or Signup to reply.
  2. In my Mac with Mojave (10.14.1) suddenly Apache couldn’t give to serve ipv4 anymore, then gave me ERROR 403. I tried to kill all apache (sudo killall httpd)… checking de PID’s on (sudo lsof | grep AMP | grep apache)… even didn’t work… just ipv6 was available… still ERROR 403.

    What works for me: Disable OSX’s built-in Apache server.

    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
    

    After that:

    sudo apachectl -k restart
    

    Be happy 🙂

    Login or Signup to reply.
  3. Try

    sudo netstat -ltnp | grep ':80'
    

    Output: tcp6 0 0 :::80 :::* LISTEN 1500/apache2

    sudo kill 1500
    sudo service apache2 restart
    
    Login or Signup to reply.
  4. this error ocurs because apache server listen by deafult in port 80 so another service or program is using that port and apache canot start.

    The solution is identify what program or service is using that port an then close, disable or unistall it.

    to identify you can run netstat

    sudo netstat -ltnp | grep ':80'
    

    or

    sudo lsof -i:80
    

    in my case i have installed nginx and apache at the same time and both uses the port 80.

    Temporary Solution: Stop or kill the service, program, etc.

    Permanent Solution:

    1. Change the port of apache server in config file
      /etc/apache2/apache2.conf
    2. Uninstall the service or program that uses port 80.

    in my case I needed both so I decided to temporarily fix it by disabling the service with:

    systemctl stop MyServiceName.service
    

    If it is a service otherwise use kill command.

    Login or Signup to reply.
  5. This one helped me:

    Please edit httpd.conf file.

    /usr/local/etc/httpd/httpd.conf
    

    And replace

    Listen 80
    

    with

    Listen 127.0.0.1:80
    

    Restart apache

    sudo apachectl -k restart
    
    Login or Signup to reply.
  6. I had my configuration set up this way before as well, and ran into the same problem after I upgraded OSX this last time. I tried to find ANYTHING that was listening on either port 80 or 443 and couldn’t find a thing anywhere. It took me a while but finally found another article that described a fix that actually worked. Keep in mind I’m using a homebrew install and have unloaded the default apache2 install that comes with Mac OSX.

    Here’s what I had before in my httpd.conf:

    Listen 80
    

    and I had something similar in ssl.conf

    Listen 443 https
    

    I had to alter my httpd.conf file to use a ServerName of localhost and Listen on 0.0.0.0:80, and same for ssl.conf but 0.0.0.0:443 https

    httpd.conf:

    ServerName localhost
    Listen 0.0.0.0:80
    

    and ssl.conf

    Listen 0.0.0.0:443 https
    

    Once I tried starting it again, everything was happy. Hope that helps! I would link to the article but I’m having trouble finding it again!

    Login or Signup to reply.
  7. Well, it looks as if httpd is already running. To check run

    lsof -i TCP:80
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    httpd 281 root 3u IPv6 19479 0t0 TCP *:80 (LISTEN)
    ….

    So kill httpd and do what you want

    Login or Signup to reply.
  8. If you’ve recently done a software update and you renamed or removed any of the default files in /etc/httpd/conf.d/ go have a look there. You might have duplicate directives because the package manager re-installed them.

    In my case, I prefixed the files with numbers so I could control the load order… but an OS update re-installed the original files so
    I had two files with "Listen 443" in them which conflicted and wasn’t caught by the syntax check. Removing the os files fixed the issue.

    (This time I left them but made them empty so the conflict will be displayed on re-install or update)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search