How to fix Node.js connect only working on localhost?

Sometimes, we want to fix Node.js connect only working on localhost.

In this article, we’ll look at how to fix Node.js connect only working on localhost.

How to fix Node.js connect only working on localhost?

To fix Node.js connect only working on localhost, we can call listen with '0.0.0.0'.

For instance, we write

const app = connect().use(connect.static("public")).listen(3000, "0.0.0.0");

to call listen with '0.0.0.0' to listen to traffic from outside localhost.

Conclusion

To fix Node.js connect only working on localhost, we can call listen with '0.0.0.0'.