Apache suddenly stopped working

apache-2.2localhost

After using apache in a local dev setup it has suddenly stopped working. I have tried pinging a previously used custom domain and I'm not getting anything.

I have checked the syntax its correct according to apache. I have made sure that my custom domain is in my hosts file. All seems ok.

I have tried this sudo bash -x /usr/sbin/apachectl -k start and still nothing. Error or access logs don't show any errors or warnings.

I have also checked the permissions of the folder I'm trying to accesses and it is drwxrwxrwx and a random file inside of the folder has -rwxrwxrwx@ and the parent folder is drwxrwxrwx 34 _www staff 1.1K Feb 4 20:06 www

There were no changes to my httpd file, but I checked it anyways. I tried disabling it Include /private/etc/apache2/other/*.conf (which contains virtual hosts) and Include /private/etc/apache2/extra/httpd-vhosts.conf and added one of the previously working vhosts at the end of the httpd file.

Not sure how to proceed as there is no error or flags. The only thing that might have changed are the permissions, but it did work after changing it.

edit: should also add that I'm on Mountain Lion.

Best Answer

After more troubleshooting and research I ran file -b /etc/hosts and to my surprise line endings had changed. For the hosts file to work, the output from the command can only be ASCII English text, anything about line endings will brake it and cause your DNS to stop working. To fix it, I ran:

tr -d '\r' < /etc/hosts > output.txt and then replaced my hosts file with the new output.txt. After that, I used vim to add line breaks again

Related Topic