Env file location at self-hosted npm installation

I’m working on a self-hosted deployment via npm not docker and I am quite lost at where to place the env file
so far I tried to add it to the .n8n folder at the home folder but did not work
I even added the environment variables at the /etc/environment file and sourced it so I can echo the variable but n8n still not recognizing the environment variables

what am I doing wrong ?
my deployment is on Ubuntu 20.04 server

by the way I can run the application fine and I can even run workflows but I am trying to migrate to Postgres Database instead of SQLite

Hi @Mohammad_Al-Qurashi and welcome :wave:,

The environment file does not have to be stored in a specific folder, but the path must be passed as an environment variable via the command line before startup. See: Configuration - n8n Documentation

The best environment for starting and controlling n8n is in my opinion the tool pm2. With the Ecosys file of pm2 you can control the environment variables very well: PM2 - Ecosystem File

1 Like

Thank you so much @BillAlex for your feedback
if I understand correctly that it would be safe to add the environment variables to the /etc/environment file ( for test proposes ) and n8n will pick up those environment variables as long as I can echo them from the terminal?

I wouldn’t be so sure about that. But I’m also not very familiar with the behavior of node and npm. But if n8n uses the appropriate variables after exit and restart, there should be no problem.

Nevertheless I would recommend pm2.