# Setup via PM2
PM2 is a daemon process manager that will help you manage and keep your application online. It allows you to wrap a Node.js application into a service. You can deploy n8n via PM2.
We don't officially support running n8n via PM2. You should follow the instructions mentioned here to deploy n8n via Docker.
To run n8n via PM2, you need to have the following software installed:
- Node.js and npm: You can find instructions on how to install both using nvm (Node Version Manager) here (opens new window). The current minimum version is
14.15. In case you already have installed Node.js, you can check your current version with the following command:
- PM2: You can install PM2 globally with the following command:
npm install pm2 -g
- n8n: You can install n8n globally with the following command:
npm install n8n -g
# Start n8n
To start the n8n service via PM2, execute the following command:
pm2 start n8n
# Auto-start on machine restarts
PM2 can generate startup scripts and configure them to keep your process list intact across expected or unexpected machine restarts.
Refer to the official PM2 documetation (opens new window) to learn about configuring the auto-start script.
# Update n8n
To update n8n, follow the steps mentioned below:
- Stop the n8n service
pm2 stop n8n
- Install the latest version of n8n
npm install -g [email protected]
- Restart the n8n service
pm2 restart n8n
You can set environment variables to override the default n8n configurations. For example, if you want to enable basic authentication for your n8n service, use the following command:
N8N_BASIC_AUTH_ACTIVE=true N8N_BASIC_AUTH_USER=USERNAME N8N_BASIC_AUTH_PASSWORD=PASSWORD pm2 restart n8n --update-env
You can learn more about all the possible configurations here.
If you want to set these configurations via a file, refer to the PM2 documentation (opens new window) to learn more.
# How to run n8n with PM2 on Windows?
To run n8n via PM2 on Windows, execute the command
pm2 start n8n from the start directory
Note: If you have installed n8n in a different directory execute the above-mentioned command from that directory.