Connect to localhost:3000 from another computer | expressjs, nodejs

elreeda picture elreeda · Jun 8, 2015 · Viewed 76.5k times · Source

I'm currently working on a project and I would like to test it from another computer or phone. This computer is connected on the same network.

How can I connect to http://localhost:3000?

I'm using expressjs (nodejs module ) as server.

Answer

Bidhan picture Bidhan · Jun 8, 2015

Configure your application to run on 0.0.0.0 instead of 127.0.0.0(localhost). For example:

app.listen(3000, '0.0.0.0', function() {
    console.log('Listening to port:  ' + 3000);
});

Then from another computer, connect to 192.168.1.11:3000 (or whatever your local IP address is).