express app server . listen all interfaces instead of localhost only

前端 未结 3 860
时光取名叫无心
时光取名叫无心 2020-12-14 05:47

I\'m very new for this stuff, and trying to make some express app

var express = require(\'express\');
var app = express();

app.listen(3000, function(err) {
         


        
3条回答
  •  独厮守ぢ
    2020-12-14 06:22

    If you use don't specify host while calling app.listen, server will run on all interfaces available i.e on 0.0.0.0

    You can bind the IP address using the following code

    app.listen(3000, '127.0.0.1');
    

提交回复
热议问题