We often see example hello world code for Node that creates an Http Server, starts listening on a port:
const http = require('http');
const server = http.createServer((req, res) => {
console.log("Hello World!!!");
});
server.listen(); //This will start our node server
So, in above what is the default server's port in which it is started?
If you check the expressjs
official documentation of app.listen([port[, host[, backlog]]][, callback])
method here
You see that there comes: If port is omitted or is 0, the operating system will assign an arbitrary unused port, which is useful for cases like automated tasks (tests, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With