You often see example hello world code for Node that creates an Http Server, starts listening on a port, then followed by something along the lines of:
conso
If you did not define the port number and you want to know on which port it is running.
let http = require('http'); let _http = http.createServer((req, res) => { res.writeHead(200); res.end('Hello..!') }).listen(); console.log(_http.address().port);
FYI, every time it will run in a different port.