How do I setup basic login for n8n installed with npm?

https://docs.n8n.io/reference/security.html - I want to add a basic authentication for my n8n instance. But I installed n8n using npm, not docker. I cannot use it with docker for server-related issues. It would be great if I had some way to implement the basic login security feature on my instance.

How are you running n8n? You just need to set the environment variables, and how to do that will depend on how you are running n8n.

If you are just running it from the command line, set the environment variables before starting n8n.

export N8N_BASIC_AUTH_ACTIVE=true
export N8N_BASIC_AUTH_USER=<USER>
export N8N_BASIC_AUTH_PASSWORD=<PASSWORD>
n8n

You can also configure the basic auth using the configuration file: https://docs.n8n.io/reference/configuration.html#configuration-via-file

1 Like