I’m trying to setup basic auth as described in manual: Key concepts | Docs
There are no problems running n8n directly but when I use pm2 to start it, main page is open and basic auth simply does not work. I’ve tried to pass env variables to pm2 but still no success. Are there any n8n specific configuration file where I can enable auth or another way how to use pm2 with variables that n8n will handle?
Welcome to the community
I am no expert with PM2 and I have a very limited knowledge. However, a quick search on the internet and I learned that you have to combine the pm2 command when you are declare the variables (I might be wrong). Here are a few links that might help:
I’m not sure why I didn’t read pm2 documentation carefully lazy me But anyway thank you for links.
The second one help me. What I needed to do was:
N8N_BASIC_AUTH_ACTIVE=true N8N_BASIC_AUTH_USER=user N8N_BASIC_AUTH_PASSWORD=pass pm2 restart n8n --update-env
Now it works even after restart.
Awesome! I am glad that it worked out! Thanks for sharing the solution
I did this and now n8n won’t start the web interface and is shown at 0% CPU & 0MB RAM in pm2 monit, did i do something wrong?
Did you find a solution?
I wrote a blog post on how to set up n8n via PM2. Maybe that can help: How to set up n8n via PM2
I wasn’t really familiar with pm2 and thought using
pm2 stop n8n would be enough to restart it, but it wasn’t, I then used
pm2 kill and restarted it and now it’s working like a charm.