Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does node.js server need internet connection to run?

I disable the internet connection and run the node server npm start, then it throws the error:

enter image description here

And now enabling internet connection and running the server works fine:

enter image description here

So, I want to confirm if this really needs to be connected to the internet while starting the server?

If it really needs internet connection, then is there any idea to run the server offline?

If I connect to the internet and run the server and there after plug out the internet connection then there's nothing goes wrong. Everything works fine. I don't know why just running the server requires the internet connection.

like image 844
Bhojendra Rauniyar Avatar asked Jul 09 '15 19:07

Bhojendra Rauniyar


1 Answers

OMG! It's really cool! I got it working offline after hard research in my code using 127.0.0.1 instead of localhost for mongo uri.

Using localhost needed for me to connect to the internet.

And using 127.0.0.1 worked in both condition i.e. with internet connection and without internet connection.

But, really I'm totally amazed of this.


I found the really cool topic on this which made me clear about this.

If you use 127.0.0.1, then (intelligent) software will just turn that directly into an IP address and use it.

And there's no guarantee that your hosts file will actually be used for that resolution (first, or at all) so localhost may become a totally different IP address.

like image 108
Bhojendra Rauniyar Avatar answered Sep 18 '22 06:09

Bhojendra Rauniyar