Create environment with access to n8n self host

I have installed n8n in my self host, but n8n can be accessed by anyone and change my workflows and see my data.
Is there some way to close this access?

Thank you.

Welcome to the community @Anderson_Rogerio_Gab

You might want to set the env variables N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD

Thank you @RicardoE105
I’m using npm already did the command:

export N8N_BASIC_AUTH_USER=user1

It should works, all right?
However anyone can be access, keeping without protected.
Is there another way to set this env variables?

@Anderson_Rogerio_Gab did it prompt you for the credentials? How did you install n8n?

I installed with ‘npm install n8n’ without -g because I’m hosting on Cloudways and it not possible install globally.
So I run n8n with $(npm bin)/n8n start.
But I change variable of database to MariaDb and it works very well.
And when I change the variables to basic auth it not works.

Did you set the environment variables in the same terminal/environment n8n got started in? If you did set it later, did you restart n8n?

Honestly still have a hard time understanding how you start/run n8n. Do you use something like pm2? If so did you check out this blog-post?

My money is on the environment variables not being set in the environment or it isn’t being picked up properly on launch.

Can you share the full set of commands you are running maybe someone can give it a quick test locally to see what happens.

I was setting env wrong! :stuck_out_tongue_winking_eye:
I’m using PM2, so I have a file with command shell to run n8n start, I added the variables before!
Thank you very much guys!

Look my file →

export N8N_HOST=<>
export N8N_PROTOCOL=https
export N8N_BASIC_AUTH_PASSWORD=********
export DB_TYPE=mariadb
export DB_MYSQLDB_HOST=localhost
export DB_MYSQLDB_PORT=3306
$(npm bin)/n8n start


Glad to hear. Have fun!

:+1: nice to hear you are up and running

@Anderson_Rogerio_Gab - So you got n8n working on cloudways?
Would be happy if you could shed some light on how you got it all working.
I am trying to do that same and I bet there is just something small I am overlooking.
I don’t know where to start :slight_smile: