.env on ubuntu npm

Hello, I have installed successfully n8n using npm, and it’s running as it supposed to do using n8n start and n8n start --tunnel (for resting) however when I created .env file in the same folder as I execute n8n start the settings are not acquired. I have set up user and password, it’s not prompting for it therefore I assume the whole .env is not being read. any suggestions?

thank you in advance

Welcome to the community @marcondy!

Did you only set user and password? That would not work. You also have to tell n8n to use them by activating basic auth with N8N_BASIC_AUTH_ACTIVE=true.

If you create a file called .env and save it in the folder you start n8n from with the following content

N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=myUser
N8N_BASIC_AUTH_PASSWORD=myPassword

it should work fine. At least for me, it does.

Here the documentation for basic auth:

how could I have missed that part!

thank you!!! you are the boss

Happy to hear that it works. Have fun!

Totally stupid question, I tried installing this on Ubuntu using NPM following your script here: n8n-pi/simple-install.sh at master · TephlonDude/n8n-pi · GitHub

Where does the .env file go in this case if I want to secure with password etc?

Hey @nin9creative,

That looks like the script you have found is using PM2 so it will pick up the .env file from the directory you are in when you run the command.

For PM2 you may be better off following the steps in this post: How to set up n8n via PM2 which covers a better way to handle it with the ecosystem.config.js file instead.

You could also try adding the .env options to your bash profile.