I wanted a very simple local http server for testing, and heard about Node.js's http-server module:


A simple zero-configuration command-line http server http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.

I've installed it with NPM and the instructions from here look wonderfully simple:


http-server [path] [options]

After I remembered to wrap my folder directory in double quotes so it wouldn't trip up on spaces in directory names, it appeared to "just work":

enter image description here

...except it defaults to serving up my local content on my public IP address (the one I blanked out in the screenshot) in addition to 127... and 192....

I only want localhost (127...) but I can't see any relevant option in the options in the documentation (it mentions "address" but says the default address is

I must be missing something obvious here. How do I set it to only serve to localhost / and not include the others?


It's really easy, it is the -a address option you use. Just add -a after the directory:

http-server "C:\some path\to\some directory\" -a

It's in the documentation, but I'd been confused by the reported default value:

-a Address to use (defaults to

Presumably, when it says "defaults to", it means something like "defaults to which in turn defaults to some system default" (like the set of three IP addresses above).

  • 1
    Listen on, on all systems I know, means listen on all available addresses. – user2313067 Sep 10 '16 at 8:09
  • Aha, didn't know that, the docs make sense now – user56reinstatemonica8 Sep 10 '16 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.