Categories
JavaScript Answers

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

Spread the love

To fix Node.js connect only working on localhost, we 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 for requests from all IP addresses.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published.