Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my mac it resolve the computer-name or localhost or ipaddress of course. But i'm trying to use my phone to access the server setup on my machine but I can only resolve it using my mac's ip address but not the mac's computer name. Any reason on why this is? Also I have modified the /etc/hosts file to map my computer's ip address to name like mypc.dev. And tried to access mypc.dev/ on my phone but it cannot resolve the dns as well. Any advice on how to proceed?

share|improve this question

migrated from stackoverflow.com Dec 24 '12 at 12:54

This question came from our site for professional and enthusiast programmers.

    
This is off-topic as it is not a programming problem. However, you should also include the model of your phone, and it's operating system. –  RB. Dec 24 '12 at 12:07

1 Answer 1

up vote 2 down vote accepted

Whatever you set in your /etc/hosts only works for your local machine, not for any other machine, not even when it's in the same network.

So what you have to do in order to get the name to work is use/set the actual hostname for the machine. I'm no OSX guru, but I believe it's pretty similar to Debian systems, so it should be under /etc/hostname. You can also temporarily change it with the hostname command, like:

hostname mypc

After you've done that, you also need to make your webserver "listen" on this hostname. By default, it only listens to IP or localhost connections. You'll have to tell it that it should listen on the mypc name. There should be something like this in the default Apache configuration:

ServerName localhost

Either change that to your desired name, or add an alias for mypc right underneath that line, like this:

ServerAlias mypc

Then restart Apache and it should start listening on that name.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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