Start local server at specific ip, node.js

I created a server

http.createServer(function(req, res){
    // ...
}).listen(3001);

      

And it works for localhost

, so in the browser I can get it http://myipaddress:3001/

. Also I can get it from any computer on the local network.

But if someone else clones this project (someone who is not on the local network) and starts their local server, they will get it through http://HISipaddress:3001/

because they have a different IP address.

Is there a way to start the server at a specific IP address, so the server will be accessible the same way?

+3


source to share





All Articles