Categories
JavaScript Answers

How to close Node Express server?

Spread the love

To close Node Express server, we call close on the server instance.

For instance, we write

const server = app.listen(3000);
server.close((err) => {
  console.log("server closed");
  process.exit(err ? 1 : 0);
});

to call server.close to close the server.

We call it with a callback that’s called when the server is closed.

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 *