N8N - update version
This guide explains how to update an existing n8n instance to the latest version. The procedure uses npm to update n8n globally while preserving all data, workflows, credentials, and configuration.
Before you begin, ensure you have:
- SSH access to the server running the n8n instance
- Administrative privileges (sudo access)
- Backup of database (recommended before any major update)
First, connect to the server hosting the KVM virtual machines:
ssh vm-admin@your-kvm-host-server
List all virtual machines and get the IP address of your n8n instance:
sudo virsh list --all
sudo virsh domifaddr vm-company-production-n8n
Example output:
Name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet0 52:54:00:12:34:56 ipv4 192.168.122.100/24
Connect to the n8n virtual machine using SSH:
Replace 192.168.122.100 with the actual IP address from Step 2.
Alternatively, if you have configured the hostname in /etc/hosts:
ssh webapp@vm-company-production-n8n
You are now connected to the n8n instance and ready to proceed with the update.
If you want to update Node.js to the latest LTS version, do this before updating n8n:
Check current and available versions:
# Current Node.js version
node --version
# Latest available LTS version
nvm ls-remote --lts | tail -1
Important: N8n typically requires Node.js 18.x or 20.x (LTS versions).
Check compatibility at https://docs.n8n.io/hosting/installation/server-setups/
Update procedure:
Stop n8n service:
sudo systemctl stop n8nCheck current n8n version (to reinstall the same version):
n8n --versionNote the version number (e.g., 1.20.0).
Update Node.js via NVM:
nvm install --lts nvm use --ltsReinstall n8n (same version, for compatibility with new Node.js):
npm install -g n8n@<version>Replace
<version>with the version from step 2 (e.g.,[email protected]).Update Node.js permissions:
NODE_PATH=$(which node) sudo setcap 'cap_net_bind_service=+ep' "$NODE_PATH"Start service:
sudo systemctl start n8n
Note: All commands in this procedure assume you are logged in as the webapp user (as per Step 3 above). NVM is automatically loaded in your shell session.
Stop the n8n service to ensure safe update:
sudo systemctl stop n8n
sudo systemctl status n8n
Before updating, check the currently installed version:
n8n --version
Update n8n to the latest version using npm:
npm update -g n8n
This command will:
- Update n8n to the latest available version
- Update all dependencies
- Preserve the existing installation in the NVM environment
Check that n8n has been updated successfully:
n8n --version
Compare with the version from Step 2 to confirm the update.
Start the n8n service with the updated version:
sudo systemctl start n8n
sudo systemctl status n8n
Check service logs for any errors or warnings:
sudo journalctl -u n8n -n 50 -f
Look for:
- Successful database connection
- Successful startup messages
- The new version number in logs
- No error messages
Access the n8n web interface and verify:
- Application loads correctly
- Existing workflows are present
- Credentials are intact
- You can execute test workflows
If the service fails to start after update:
Check logs for specific errors:
sudo journalctl -u n8n -n 100Verify Node.js permissions:
NODE_PATH=$(which node) sudo getcap "$NODE_PATH"Check configuration file is still valid:
cat /home/webapp/.n8n/.env
If there are database migration errors:
Check database connection:
sudo -u postgres psql -c "\l"Review migration logs in journalctl output
Restore from backup if necessary (ensure you have a backup before updating)
If you encounter permission errors:
Verify file ownership:
ls -la /home/webapp/.n8n/Fix ownership if needed:
sudo chown -R webapp:webapp /home/webapp/.n8n
If the update causes issues and you need to rollback to a previous version:
Stop n8n service:
sudo systemctl stop n8nInstall specific version:
npm install -g n8n@<version>Replace
<version>with the previous version number (e.g.,[email protected])Restore Node.js capabilities:
NODE_PATH=$(which node) sudo setcap 'cap_net_bind_service=+ep' "$NODE_PATH"Start service:
sudo systemctl start n8n
This procedure safely updates n8n by:
- Stopping the n8n service
- Updating the n8n package via npm
- Restarting the service
- Verifying successful update
The update preserves all data, workflows, credentials, and configuration. The process typically completes in 1-2 minutes depending on your server and network speed.
Note: If you need to update Node.js as well, use the “Updating Node.js (Optional)” section at the beginning of this guide before updating n8n.
