While using http.createServer() method on Node.js, I am unable to use any other address than '127.0.0.1'. My understanding is that I should be able to use any address under Class A IPv4 addresses, but it is not true as I am thrown an error.
Can someone kindly help me understand this?
Terminal error log:
Code:
const http = require('http');
const hostname = '127.0.0.1';
const port = 1337;
http.createServer((request, response) => {
response.writeHead(200, { 'Content-Type': 'text/plain' });
response.end('Hello World\n');
}).listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});