I have Apache installed and the server directory index was accessible using http://localhost before I recently installed a new Dlink ADSL2+ Modem+Router . Now the apache web server contents are only accessible using the address in the web browser. Using http://localhost displays a "403 Forbidden (nginx)" message. When I unplug my ethernet cable from the PC and restart networking , localhost leads to the apache index.

I have tried assigning a new domain name 'localwebserver' in the /etc/hosts file to but then the browser displays a message "Critical error: no domain selected!"

My /etc/hosts file avinash-ubuntu localhost localwebserver

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

My /etc/network/interfaces file

auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp

nslookup localhost :


Non-authoritative answer:
Name:   localhost.home.network

What could possibly be changed when I plug in the new router? How can I get localhost to display the apache index? Haven't found any option on the modem config page that seems related (to my knowledge)


  • Could you share result of nslookup localhost May 12, 2017 at 9:57
  • I have added it in the post
    – Parapan
    May 12, 2017 at 10:17

1 Answer 1


Looks like your DHCP server add search directive in your /etc/resolve.conf. And host with name localhost.home.network exist in Internet, so you try to connect to it instead of your host. Try to change DHCP configuration on your router(change domain from home.network to something else, like myhome.local).

  • I am not sure how that setting was affecting this but I changed the interfaces setup to static for now anyways and the search entry has been removed from resolv.conf. Works fine now, thanks
    – Parapan
    May 12, 2017 at 11:06
  • 1
    Microsoft discourages (as do I) using the TLD .local - the proper method is to use a domain or subdomain you have full control over. May 12, 2017 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .