Nodejs was unable to establish an http server.

  node.js, question
var http = require("http");
 var url = require("url");
 
 var date = new Date();
 
 var server = http.createServer((req,res) => {
 var reqUrl = url.parse(req.url);
 var path = reqUrl.pathname;
 
 if (path == "/apt/parsetime") {
 apiParseTimeHandler(req,res);
 bracket
 
 var isoTime = date.toISOString();
 res.write(isoTime);
 });
 
 function apiParseTimeHandler(req,res) {
 res.writeHead(200,{
 "Content-Type": "application/json",
 });
 
 var dateJson = {};
 dateJson.hour = date.getHours();
 dateJson.minute = date.getMinutes();
 dateJson.second = date.getSeconds();
 dateJson = JSON.stringify(dateJson);
 res.write(dateJson);
 bracket
 
 server.listen(process.argv[2]);

After operation
Connecting to an established server always gets error connecting.

Because you have to callres.end()The response is over. As follows:

15     res.write(isoTime);
 16     res.end();

This will do.