1. Home
  2. Web Hosting
  3. NodeJS
  4. Ports running NodeJS

Ports running NodeJS

Table of Contents

Our cPanel servers use CloudLinux NodeJS selector, CageFS, and LiteSpeed Web Server.

When managing a NodeJS app with a CloudLinux NodeJS selector, LSWS is a proxy for ws:// requests to the NodeJS backend when a WebSocket upgrade is requested. Best of all, no additional configuration is needed!

When testing a direct connection to a NodeJS server, use the following command:

ws://...

When accessing a NodeJS server through an LSWS HTTPS proxy server, use the following command:

wss://...

When a NodeJS server is started, the TCP socket is replaced with an auto-generated Unix domain socket. Hence, direct access to the TCP port may fail.

To test, you can create a file with the name index.js. Place the following content in the file:

var http = require('http');
var server = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    var message = 'Yaay! It works!\n',
        version = 'NodeJS ' + process.versions.node + '\n',
        response = [message, version].join('\n');
    res.end(response);
});
server.listen();

Point your browser to http://domain.com/index.js and the result should be:

Yaay! It works!
NodeJS 10.0

Note! Any port specifications in the listen function are ignored. The server is processed by the Node.js function of LiteSpeed automatically.

Conclusion

When running a NodeJS server, the web server proxies the ports through ports 80 and 443. We do not open any additional ports for security reasons.

If you are running a NodeJS server, please ensure that you run it on either port 80 or 443.

Updated on January 24, 2024

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support