0

I am on Mac Yosemite. Apache 2.4.16. My localhost and local sites stopped working. They've been working fine for months now until I tried to update/fix MySQL. I get the following error:

This site can’t be reached
localhost refused to connect.
ERR_CONNECTION_REFUSED

Results for ps aux | grep "httpd":
3182 0.0 0.0 2432772 652 s002 S+ 8:46AM 0:00.00 grep httpd

The numbers in the line above change each time I run ps aux | grep "httpd". Not sure if this is expected.

When I run killall -9 httpd:
No matching processes belonging to you were found

My host file:

##
# 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 
fe80::1%lo0 localhost

127.0.0.1 test.local

httpd-vhost.conf:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#


<VirtualHost *:80>
  DocumentRoot "/Users/<myusername>/projects/test"
  ServerName test.local
  <Directory "/Users/<myusername>/projects/test">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>

I changed my actual username to for this post only.

apachectl configtest returns:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using <myusername>-iMac.local. Set the 'ServerName' directive globally to suppress this message Syntax OK

Results of sudo launchctl print-disabled system:
disabled services = { "com.apple.AppleFileServer" => true "com.apple.hdiejectd" => false "com.apple.screensharing" => true "com.mysql.mysqld" => false "com.apple.ManagedClientAgent.enrollagent" => true "com.barebones.textwrangler" => false "com.apple.usbmuxd" => false "com.apple.odproxyd" => false "com.apple.rpmuxd" => false "com.apple.ftpd" => true "com.apple.mrt" => true "com.apple.smbd" => true "org.apache.httpd" => false "com.apple.stackshot" => false "com.apple.ManagedClient.enrollagent" => true "org.ntp.ntpd" => false "org.net-snmp.snmpd" => true "com.apple.mrt.uiagent" => false "org.macosforge.xquartz.privileged_startx" => false "com.apple.pacemaker" => true "com.apple.flashupdater" => false }

srodrig
  • 11
  • 2

1 Answers1

0

That grep line means that the only reference to the searched for string in the process list is the process doing the search. So it isnt running. Use launchd to restart it.

Jonah Benton
  • 1,242
  • 7
  • 13
  • I did `sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist` and get: `/System/Library/LaunchDaemons/org.apache.httpd.plist: Operation already in progress` – srodrig Sep 16 '16 at 13:09
  • Check the quarantine and for disabled services, eg http://pablotips.blogspot.com/2015/02/tomcat-doesnt-starts-on-boot-yosemite.html – Jonah Benton Sep 16 '16 at 13:33
  • Running xattr -r -d com.apple.quarantine /opt/servers/Tomcat/TomcatHome returns: `xattr: No such file: /opt/servers/Tomcat/TomcatHome` sudo launchctl enable org.apache.tomcat returns: `Usage: launchctl enable ` sudo launchctl bootstrap system /Library/LaunchDaemons/org.apache.tomcat.plist returns: `/Library/LaunchDaemons/org.apache.tomcat.plist: No such file or directory` – srodrig Sep 16 '16 at 13:44
  • Tomcat is a different service from httpd- the intention of that comment is to suggest use of those techniques on the httpd service... – Jonah Benton Sep 16 '16 at 13:46
  • Oh I see, thanks for clarifying. Do I just replace Tomcat with httpd then? Sorry not very familiar with this sort of stuff – srodrig Sep 16 '16 at 13:53
  • I added in original question: apachectl configtest returns: `AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using -iMac.local. Set the 'ServerName' directive globally to suppress this message Syntax OK` – srodrig Sep 16 '16 at 14:02
  • That apachectl configtest is fine. Try doing the original command but with "unload" rather than "load", then try "load" again. If that doesnt help share the results of "sudo launchctl print-disabled system" – Jonah Benton Sep 16 '16 at 14:44
  • Added results of `sudo launchctl print-disabled system` to original question. Too long for comments – srodrig Sep 16 '16 at 15:07
  • Here is the last error from apache error_log: `[core:warn] [pid 80] AH00045: child process 27856 still did not exit, sending a SIGTERM` – srodrig Sep 16 '16 at 15:20
  • Worth a reboot and try again- did that already happen? – Jonah Benton Sep 16 '16 at 15:31
  • I say that because the service is NOT disabled (disabled is false for httpd). So on a reboot it should start normally. – Jonah Benton Sep 16 '16 at 15:49
  • Yes, I had previously rebooted and just did now. Did sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist and get: `/System/Library/LaunchDaemons/org.apache.httpd.plist: Operation already in progress` – srodrig Sep 16 '16 at 16:03
  • I think the issue had to do with PHP being hung up. Apache started working for me but there error log showed this: ```[mpm_prefork:notice] [pid 1207] AH00163: Apache/2.4.16 (Unix) PHP/5.5.36 configured -- resuming normal operations [Fri Sep 16 12:53:20.752981 2016] [core:notice] [pid 1207] AH00094: Command line: '/usr/sbin/httpd'``` – srodrig Sep 16 '16 at 17:21
  • Great, those messages are fine, the log level is "notice" which means they can be safely ignored. :) – Jonah Benton Sep 16 '16 at 17:33
  • Interesting, so you don't think PHP was related at all? – srodrig Sep 16 '16 at 17:44
  • Not enough info to say, but if it just takes a while to start, thats fine. Glad it works now. – Jonah Benton Sep 16 '16 at 21:38