Bind expressjs to a specific IP address
node.jsExpressnode.js Problem Overview
How can i bind a expressjs server to a specific IP
Something like
app.listen(8888, '192.168.0.101');
Equivalent to nodejs:
http.createServer(onRequest).listen(8888,'192.168.0.101');
node.js Solutions
Solution 1 - node.js
ExpressJS just passes your parameters down to the http
module when you call listen, so your example should work.
Is that not the case?
Solution 2 - node.js
var server = app.listen(3000, '127.0.0.1',onServerListening);
In this case I want the server to respond only to connections using the 127.0.0.1 host name. Not 0.0.0.0, and not localhost. Only 127.0.0.1.
Solution 3 - node.js
app.set('domain', 'myhost.whatever');
app.set('port', process.env.PORT || 8080);