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
One of a couple of things could be happening:
which apachectl
. As an example, I also have two versions of apache/usr/sbin/apachectl
and/usr/local/bin/apachectl
apachectl start
as root, although it appears that you are.sudo lsof -i:80
to see what’s binding that port currentlyIn 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.
After that:
Be happy 🙂
Try
Output: tcp6 0 0 :::80 :::* LISTEN 1500/apache2
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
or
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:
/etc/apache2/apache2.conf
in my case I needed both so I decided to temporarily fix it by disabling the service with:
If it is a service otherwise use kill command.
This one helped me:
Please edit httpd.conf file.
And replace
with
Restart apache
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:
and I had something similar in ssl.conf
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:
and ssl.conf
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!
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
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)