1

I am having an issue where I setup my local apache server on my Mac OS X Yosemite. The server has been working great up until I needed to work remotely without wireless access. I have been looking all over for a solution to get the server to work when I am offline but cannot seem to yield results.

I have these settings in my .conf

Listen *:80
ServerName localhost

These in my hosts

127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

While offline I can ping 127.0.0.1 successfully but when I try and ping or traceroute to one of my vhosts domains I says host cannot be found.

traceroute example.dev

What settings can I look at in order to get this working offline? Do I need to setup a new network interface?

Note: I am not using XAMPP or MAMP. Just the pre-installed apache server on the OS.

2

You did not define example.dev anywhere, so how would your computer know it needs to map to your machine? I assume it is defined somewhere in your network though, and then maps to 127.0.0.1.

(Likewise, domains such as lvh.me and lvho.st, aka Local Virtual Host, are registered by some people who made them and al their subdomains point to 127.0.0.1.)

Note that .dev is a proposed level domain. When pinging or digging it on my machine, I see:

dig example.dev

example.dev.        3600    IN  A   127.0.53.53

...where this special IP address should ring alarm bells:

127.0.53.53 is a special IPv4 address that will appear in system logs alerting system administrators that there is potential name collision issue, enabling a quick diagnosis and remediation. The "53" is used as a mnemonic to indicate a DNS-related problem owing to the use of network port 53 for the DNS service.

I don't know how it got mapped like that in my network; maybe as the .dev domain is in a proposal state and someone already partially added it? As an aside: all .dev domains map to that IP address for me. Still then, 127.0.53.53 does not map to my local web server.

So, I assume that example.dev maps to 127.0.0.1 in your network, and to make your computer lookup the name, it needs a network connection. As using .dev might clash if the proposed top level domain is ever assigned, and as you want things to work without a network connection, you could add other aliases to your host file. Like on the line for 127.0.0.1:

127.0.0.1    localhost my.host www.my.host subdomain2.my.host another-host

You can see where that is going if you need many (sub)domains... To use wildcards without a network connection, you'd probably need to set up some DNS server on your local machine.

To quickly see if all this is indeed the issue, just add example.dev:

127.0.0.1    localhost example.dev
| improve this answer | |
  • Thank you for taking the time to help me out. I added 127.0.0.1 localhost example.dev to my hosts and that vhost started to work. So I have dnsmasq setup to map all .dev domains. Which was dynamically routing as I understand. And with that I didn't need to add a hosts entry while online. – brenjt Apr 5 '15 at 20:23
  • @brenjt, are you saying you set up dnsmasq just now as a fix, or did you already use that and was that giving you problems? If you set it up now: what did you do to make dnsmasq work when not connected? (My dnsmasq installation does not actually work when I disconnect from my network, on Yosemite. I guess that is related to my resolve-file not being set in /usr/local/etc/dnsmasq.conf, hence using its default /etc/resolve.conf which does not exists when not connected. Still then Yosemite, should be able to find my /etc/resolver/mydomain files, which tell OS X to use dnsmasq...) – Arjan Apr 6 '15 at 13:05
  • Ah, see dnsmasq not working without internet connection in OS X Yosemite (no solution yet), @brenjt. – Arjan Apr 6 '15 at 13:33
  • Ah, well I guess I'll stick to manually adding the entries to my hosts file until Apple officially addresses the issue, – brenjt Apr 6 '15 at 16:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.