Skip to content
ContactWebmailCustomer panel

Hosting and Servers

How do I run a Node.js application in Plesk?

Short answer: in Plesk, Node.js applications run through the Node.js Toolkit extension. You point it to the application directory (Application Root), the public directory (Document Root), and a startup file (e.g. app.js), choose a Node.js version, install dependencies with the NPM install button, and start the application. Phusion Passenger manages the process. You don't need your own VPS or manual nginx configuration, and the new application goes live as soon as the web server picks up the new configuration. Below is the full walkthrough, a sample application, and the most common problems.

How Plesk runs a Node.js application

The Node.js Toolkit doesn't run the application in the background through pm2 or systemd. Instead, it adds Phusion Passenger directives to the web server configuration. On the first request, Passenger starts the Node.js process, passes it a port through the PORT variable, and routes the domain's traffic to it. An unused process can be shut down and will start again on the next visit.

Three practical rules follow from this:

  • the application must listen on the port from process.env.PORT, not a hardcoded 3000;
  • static files in the public directory are served by the web server, and every other address goes to the application;
  • a configuration change only takes effect after the web server reloads, which Plesk does with a delay (up to 30 minutes on our server).

Setting up a domain or subdomain

The easiest setup is to run the application on a separate subdomain, e.g. app.twojafirma.pl. Your WordPress home page then keeps working unchanged. Create the subdomain under Websites & Domains → Add Subdomain and enter the application's public directory as the document root, e.g. app/public. The application directory (app) then sits outside the public directory, so files like .env or node_modules can't be downloaded through the browser.

A minimal application and package.json

The simplest working application needs no libraries at all. Save it as app/app.js:

const http = require('http');

const port = process.env.PORT || 3000;   // port podaje Passenger

http.createServer((req, res) => {
  res.setHeader('Content-Type', 'application/json; charset=utf-8');
  res.end(JSON.stringify({ ok: true, node: process.version, path: req.url }));
}).listen(port);

With the Express library, the application looks similar. Dependencies are described in app/package.json:

{
  "name": "moja-aplikacja",
  "version": "1.0.0",
  "private": true,
  "main": "app.js",
  "scripts": {
    "build": "echo \"brak kroku budowania\""
  },
  "dependencies": {
    "express": "^4.21.2"
  }
}
const express = require('express');
const app = express();

app.get('/', (req, res) => res.json({ ok: true }));
app.listen(process.env.PORT || 3000);

Configuration in the Node.js Toolkit

In the domain's panel, open Node.js and click Enable Node.js. The key fields:

This table can be scrolled horizontally.

FieldWhat to enter
Node.js Versiona version compatible with the application; for new projects, choose an LTS version
Package Managernpm or Yarn — matching the lock file in your project
Document Rootthe public directory, e.g. /app/public
Application Rootthe directory with package.json, e.g. /app
Application Startup Filethe startup file, e.g. app.js or server.js
Application Modeproduction for a live site
Custom environment variablesyour application's variables (see below)

After saving, Plesk generates the Passenger configuration. If the public directory still has the default index.html file created when the subdomain was set up, delete it. Otherwise the web server will serve it instead of the application's response, and it will look like Node.js isn't working.

Dependencies: NPM install and scripts

The NPM install button installs dependencies from package.json in the application directory. Run script runs a script from the scripts section, e.g. build for applications with a compile step (TypeScript, Next.js in production mode). With SSH access, you can do the same from the console — just remember to point to the right Node.js version:

cd ~/app
export PATH=/opt/plesk/node/24/bin:$PATH
node -v
npm ci --omit=dev

Libraries that compile during installation (e.g. bcrypt, sharp in older versions) need build tools. On shared hosting these are sometimes unavailable, so before choosing a library, check whether it ships prebuilt binaries or has a pure JavaScript version (e.g. bcryptjs).

Environment variables

Enter passwords, database addresses, and API keys under Custom environment variables, or in an .env file in the application directory (outside the public directory). Don't keep them in your repository. Example of reading one:

const dbUrl = process.env.DATABASE_URL;
if (!dbUrl) throw new Error('Brak DATABASE_URL');

We show how to build a DATABASE_URL for a database created in the panel in our guide on PostgreSQL in Plesk.

Restart and logs

After uploading a new version of your code, the application needs to be restarted:

  • in the panel: Restart App;
  • via SSH or the file manager: create or touch the file tmp/restart.txt in the application directory — Passenger will restart the process on the next request.
mkdir -p ~/app/tmp && touch ~/app/tmp/restart.txt

Passenger prints startup errors (e.g. a missing module, wrong startup file) on the error page and in the domain's logs (Logs in the panel). Anything the application writes with console.log also ends up in the web server log.

Deploying from Git

On packages with the Git extension, you can connect a repository to the application directory and deploy changes manually or automatically after git push. Add dependency installation and a restart to the post-deployment actions, e.g.:

npm ci --omit=dev && mkdir -p tmp && touch tmp/restart.txt

Common problems

  • You see the default Plesk page instead of the application — there's an index.html in the public directory; delete it.
  • Configuration changes don't work — the web server hasn't loaded the new configuration yet; wait for the reload or ask your hosting support.
  • "Cannot find module" — dependencies weren't installed in the application directory, or Application Root points to a different directory than the one with package.json.
  • The application is listening, but nothing responds — the port is hardcoded instead of using process.env.PORT.
  • "The application process exited prematurely" — an error at application startup or in the runtime environment; check the logs for details. On hosting with account isolation (CageFS), the cause is sometimes server-side Passenger configuration — in that case you need your hosting support.
  • The application works locally but not on the server — a different Node.js version; set the panel to the same version you use locally, and record it in package.json ("engines").

FAQ

Do I need a VPS for Node.js?

Not always. An API, an admin panel, or a small Express service will run in Plesk on hosting with the Node.js Toolkit. A VPS makes sense for long-running background processes, WebSockets with heavy traffic, or custom system-level services.

Can I run Next.js?

Yes, as a Node.js application: build the project (npm run build) and point to the production server's startup file. A fully static export (output: 'export' in the Next.js configuration) just needs to be uploaded to the public directory.

How do I restart the application without the panel?

Create or update the tmp/restart.txt file in the application directory.

Where should I keep database passwords?

In the application's environment variables, or in an .env file outside the public directory — never in the repository.

Technical verification: 17 September 2026, Plesk Obsidian 18.0.80, Node.js Toolkit 2.5, Node.js 24.21 and 26.8, Passenger 6.1. Related guides: PostgreSQL in Plesk, Docker and Docker Compose in Plesk, Ruby applications in Plesk. Packages: NVMe hosting (Business) and NVMe Performance and Pro.