Categories
JavaScript Answers

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

Spread the love

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'.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published. Required fields are marked *