Reputation: 11
I have hosted a website on my Raspberry Pi and I have a weird thing going on. When I am on my local network and I want to access my website and go to www.mywebsite.com (example), it will not load. But when I enter the local ip address of the website that is hosted on my Raspberry Pi, the site is accessible.
But when I load www.mywebsite.com in any browser from a 4G network or any external network, I will be able to load it.
I was wondering whether something in the RaspberryPi is configured incorrectly with regards to apache or whether this is a problem of my router.
Upvotes: 0
Views: 967
Reputation: 116
The problem is probably not with the Pi, but with your router connecting you to the internet.
www.mywebsite.com (I guess you use some dynamic DNS service) resolves to your external IP address. You router apparently doesn't let you access the (forwarded) port of you external IP address from within your LAN. Solving this issue would very likely depend on your router brand. As pajaja noted, you might find this functionality called "NAT loopback" in your router's manual. I've also seen it called "NAT hairpin".
Alternatives:
Regarding the format of the hosts file there is a topic over at Stackexchange about it: https://unix.stackexchange.com/questions/13046/format-of-etc-hosts-on-linux-different-from-windows
[1] On unix: /etc/hosts, on Windows: C:\Windows\System32\drivers\etc\hosts
Upvotes: 2
Reputation: 435
I think the problem is the DNS server configured in your router. Try to resolve the name with the command nslookup
in some host in your local network. I think is the same command in Linux and Windows.
If you don't able to resolve the name, the problem is your DNS config.tTy to change it for other one. The Google's for example 8.8.8.8
Upvotes: 0