Running a Node.js server on a different port

nodejs

#1

When I try to run a Node.js server on port 8081 (I set the PORT environment variable to 8081), I can’t access it in a new tab when it’s running. Here’s the error I get in Chrome (the URL I’m connecting to is http://project-name-matmatpenguin.c9users.io:8081/).


And here's the code
function requestListener(request, response) {
    response.writeHead(200, {
        "Content-Type": "text/plain"
    });
    response.end("Hello World\n");
    server.close();
}

console.log(process.env.IP + ":" + process.env.PORT);
var http = require('http');
var server = http.createServer(requestListener).listen(process.env.PORT, process.env.IP);

#2

Looks like an issue with your firewall or vpn, not forwarding requests to url with port.
Cloud9 displays an error page even for projects that do not exist or have no server running.