I have a node server running on port 8080. This is for some personal development and I'm accessing my web server using localhost in my chrome browser. I'm sitting in a coffeeshop and I don't want outside users to have access to my files on my webserver.

So how do I prevent all users that are not localhost from accessing this web server? is it a node.js setting or a system setting (I'm using a mac). Thanks.

  • Do you want "localhost-only" all the time or only when outside your home network?
    – Steven
    Jun 25, 2015 at 18:43
  • only outside my apartment. in my apartment I want to be able to access this from mobile devices. so only in the coffeeshop i want to restrict to localhost.
    – foreyez
    Jun 25, 2015 at 18:44

2 Answers 2


Instead of blocking everything from a firewall, why not just have it bind to Nothing, but things on the local machine, would be able to access it then.

This can be done with express by doing:

app.listen(8080, '');

or with http:

http.createServer(onRequest).listen(8080, '');

I did this by going into

System Preferences -> Security Preferences -> Firewall -> Firewall Options -> Block all incoming connections

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.