Categories
JavaScript Answers

How to listen all interfaces instead of localhost only with Node Express app server?

Spread the love

To listen all interfaces instead of localhost only with Node Express app server, we call listen with '0.0.0.0'.

For instance, we write

const express = require("express");
const app = express();
app.listen(3000, "0.0.0.0");

to call app.listen with "0.0.0.0" to listen for all interfaces at port 3000.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.