How to run a simple node.js application in Plesk to test it working?

Started by Suhitha, Dec 16, 2025, 03:24 AM

Previous topic - Next topic

Suhitha

Applicable to:

  • Plesk Obsidian


Question

How to run a simple node.js application in Plesk to test it working?


Answer

1.Log into Plesk.

2.Go to Domains > example.com > File Manager.

3.Create a file app.js in httpdocs directory and remove index.html file:



4.Click on the file app.js in File Manager to open it in built-in text editor and put the code below:

const http = require('http');

http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end("Hello, World!\n");
}).listen(process.env.PORT);

console.log('App is running...');
5.Go to Domains > example.com > Node.js and make sure that Document Root and Application Root point to httpdocs directory where app.js file stored

6.Enable Node.js:



7.Open in a browser the http://example.com page to see how is it working:

Hello, World!