-4

I need to run a simple http-server using nodejs. I have installed in my local repo using npm. When i run the below command, i am getting th e following message

nodejs node-modules/http-server/bin/http-server -a 127.0.0.0
Starting up http-server, serving ./ on: http://127.0.0.0:8080

But, server is not running on http://127.0.0.0:8080. All i could see in the screen is, The webpage is not available

If i change the command as,

nodejs node-modules/http-server/bin/http-server -a 127.0.0.1

it starts a local server at http://127.0.0.1:8080

I do not understand what is going on. Could any body help me to understand what's happening here?

Thanks in ADVANCE!!

SELVA
  • 135
  • 1
  • 3
  • 10
  • 1
    "127.0.0.0 is the network address (with netmask 255.0.0.0 or 127.0.0.0/8). 127.0.0.1 is a host address in that network." From http://superuser.com/questions/575647/whats-the-difference-between-127-0-0-1-and-127-0-0-0 – Joshua Terrill Aug 22 '15 at 09:04

2 Answers2

2

127.0.0.0 is not a valid address.

See this article.

Kamen Minkov
  • 3,324
  • 1
  • 14
  • 21
0

First of all take a look at this question, which tells you why, while an address ending in .0 is perfectly valid, you should avoid using it (hint: legacy reasons).

Then again, node is explicitly telling you where the server is being started, you posted it in your question:

Starting up http-server, serving ./ on: ---> http://127.0.0.1:8080 <---

Even more to the point, 127.0.0.0 is not a loopback address, but a generic (potentially assignable) network address. 127.0.0.1, on the other hand, is a loopback address, which means it's assigned to your machine and it's accessible from your machine only. Take a look at this Wikipedia article.

So what can you do? Just run your application on 127.0.0.1, since you can't (and shouldn't probably) run it on 127.0.0.0.

Community
  • 1
  • 1
Gian Marco Toso
  • 11,676
  • 5
  • 29
  • 38