Question
Is it possible to change Node.js application port in Plesk?
Answer
Node.js application delivered via Plesk is executed via Passenger, that is why the port of Node.js cannot be changed.
Here is how it works:
- Passenger is compiled and set up to work as a web server module. The Passenger web server module forwards incoming requests to the Passenger core process, which starts with the web server. Passenger core is responsible for spawning new Node.js application processes (if necessary), processing incoming requests, that are forwarded by a web server (Apache or Nginx), and terminating idle Node.js instances.
Instead of using a fixed port number for your app, you may switch the usage to be for a dynamic port by editing the PORT value as follows:
port = process.env.PORT
If you would like to have a feature that would allow you to change the Node.js port within Plesk, please vote for this feature at Plesk UserVoice: