0

I know there are various documents available on web giving the steps to do this but I am not able to fix the problem -- I have an angularjs project which is running on localhost (and os is ubuntu 14.04), I want to access it via external ip.

Here is a snippet from the project's config file -

options: {
  port: 9000,
  // Change this to '0.0.0.0' to access the server from outside.
  //hostname: 'localhost'
  ...
  ...
}

I have changed localhost to 0.0.0.0 This is now allowing me to access the application by internal ip -

192.168.X.X:9000

The problem is that I can't access the same with external ip. I have a router and I have setup port forwarding in router configuration which I was hoping could solve the problem but it didn't.

I also tried adding the following line in /etc/hosts -

<my external ip>  localhost
<my external ip>  127.0.0.1

This makes no difference. I am not sure what is wrong and cant figure out even after spending few days searching for solution.

update --

This seems to be a restriction with the internet connection which is not allowing such port forwarding. Though I can successfully do a ssh port forwarding.

I tried the same on a different network and was able to access localhost by external ip.

1
  • Are you testing from an external source? Can you do sudo netstat -pant | grep 9000 on the server?
    – Paul
    Aug 27, 2014 at 6:13

1 Answer 1

1

Many routers won't accept/forward packets sent outside coming back (i.e. those meant for their own public IP). I've had such issues in the past as well.

Also, as far as I'm aware, you can't use the hosts file to redirect traffic from one IP to another. That's really just meant to define hostnames your PC won't ask the nameserver for to get their IP.

Try a service such as Web Sniffer to access your server or just some port scanning service. Is it able to do so?

Edit: if you really have to use the dynamic/public hostname, e.g. to test some server, add it to your local hosts file, but let it point to the LAN IP rather than the public/external WAN one.

You must log in to answer this question.

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