I'm having an issue accessing my Pi hostname (respbian) on my local network (similar to Can't access web server via hostname, although from my remote host (a Mac) I can telnet to the hostname and port:

my-macbook-pro-2:~ me$ telnet raspbian.local 80
Connected to raspbian.local.
Escape character is '^]'.

I can also ssh to my locally named Pi host from my Mac. But, I cannot perform an nslookup (which is not surprising, since I am not running a DNS).

However, I still cannot browse via web from my Mac to the Pi's hostname (I can to its local assigned IP). So, the billion dollar question is: If port 80 is listening on the Pi and the Pi's local hostname is being resolved (either on the Mac or at the router), then why isn't the web browser resolving the Pi's local host name (I do have it in the /etc/hosts file on my Mac, incidentally)? The router does see the Pi's name when I look at the client list via the Airport Utility.

I am using apache2 as a web server, and Raspbian as the OS, FWIW.

closed as off-topic by Ghanima, goldilocks Nov 5 '15 at 1:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Ghanima, goldilocks
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You don't mention how many other machines or what OS they are running but you can create a local (per machine) hosts file. Just search hosts file and the OS you are using. In the case of a windows machine you will want to add the version of the OD as well (e.g. win 10 hosts file) this will give you instructions on making a hosts entry for your pi. You will need the hostname and IP of the Pi. both of which can be found with ifconfig under the eth0 (wired) or wlan (WiFi) section. – Steve Robillard Nov 4 '15 at 18:03
  • Suggest you apt-get install avahi-daemon libnss-mdns on the Pi. – Mausy5043 Nov 4 '15 at 20:11
  • By gum! Installing these packages did the trick. I would select this answer as the correct one, but there is no such option. Thumbs up! – horcle_buzz Nov 5 '15 at 0:46

If port 80 is listening for this on the Pi and resolving the local hostname

I'm not sure if you're confused here or not about how name resolution works -- the bit about "port 80 listening...and resolving the local hostname" implies you are confused.

Logically enough, hostname resolution does not happen on the target system (the pi), it happens on the local system (your Mac). "Logically enough", because there is no "hostname" used in TCP/IP, there is only the IP address, so for any communication to reach the target system, the hostname must first be correctly resolved, either on the local machine via its own mechanisms, or via DNS lookup, which, once again, logically cannot, except by pure coincidence (e.g., you are running a DNS server on the same system, which the local machine uses by IP) involve the target system.

In this case, since you can use the hostname correctly, it is either configured on the Mac (e.g., via LAN zeroconf, which is probably enabled on both systems; Raspbian uses avahi for this) or else relies on DNS resolution via the router.

That the hostname does not work on the Mac browser then implies one of two causes:

  1. The browser or local OS is causing the problem.

  2. The web server is rejecting the request. A hostname is used in HTTP headers, and apache or software it dispatches to may be configured to only accept requests with a specific name.

To definitively distinguish between the two possibilities, you could watch the transaction from one side or the other using a tool such as wireshark.

In any case, questions about OSX and OSX software are off-topic here and belong on Ask Different. Questions about apache configuration are also off-topic but might be appropriate on Unix & Linux, Server Fault, or perhaps Stack Overflow. As a clue, I would find out where the server logs to and check those logs to see if it is rejecting requests based on hostname. If this is the case, again, apache configuration is a topic better researched elsewhere, including the official documentation.

If in fact your problem is a browser on the pi (i.e., the same system the server is running on), edit /etc/hosts and to the end of the localhost.localdomain line (probably the first one), add raspbian.local.

  • Thanks, you are correct about name resolution. I had typed this rather quickly when I posted it. I just edited my question to reflect this. – horcle_buzz Nov 4 '15 at 20:46
  • Apache's logs by default will be somewhere in /var/log -- either the obvious /var/log/apache or perhaps /var/log/httpd. If it is rejecting requests, you'll see some indication that it at least received them in there, then if so you just need to figure out how to get it to accept whatever host name. – goldilocks Nov 4 '15 at 21:18
  • Apache logs are clean. Hosts file on both the Pi and Macbook are configured correctly. And I can access raspbian.local via the Pi's browser... – horcle_buzz Nov 5 '15 at 0:40
  • Then you might as well treat this as an opportunity to get acquainted with wireshark. There's a drop dead simple difference in possibilities involved: Either the local system actually is sending packets to the target, or it is not. The possible solutions in one case are completely different than the other. – goldilocks Nov 5 '15 at 1:01
  • I will definitely take a look, since I have other uses for it (I assume it is a network sniffer). In any case, @Mausy5043 gave the answer, but I could not select it, since it was only a comment. I couldn't even up-vote it either. – horcle_buzz Nov 5 '15 at 1:22

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