Learn how to secure your n8n instance with basic auth using simple steps to protect workflows and keep your automation environment safe.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
The simplest and correct way to secure n8n with Basic Auth is to set two environment variables where n8n runs: N8N_BASIC_AUTH_ACTIVE=true and a username/password via N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH\_PASSWORD. Once you restart n8n, anyone visiting the n8n editor or any endpoint that is not a webhook must enter this Basic Auth username and password.
Basic Auth in n8n protects the n8n editor UI and the REST API. It does not protect public webhooks. n8n webhooks always stay public unless you secure them yourself with keys, signatures, or custom logic in the workflow.
Basic Auth is essentially a “login wall” your browser shows before you can see the n8n UI. It’s not fancy, but it’s reliable and simple, which is why it’s the recommended minimum security when your instance is exposed to the internet.
You secure n8n with Basic Auth by setting the following environment variables wherever n8n runs (Docker, server, or cloud):
// Enable Basic Auth
export N8N_BASIC_AUTH_ACTIVE=true
// Choose your login username
export N8N_BASIC_AUTH_USER=admin
// Choose a strong password
export N8N_BASIC_AUTH_PASSWORD="a-strong-password"
If you use Docker, this goes into your docker run command or your docker-compose.yml file. After setting the variables, restart the n8n service so the settings take effect.
services:
n8n:
image: n8nio/n8n
environment:
N8N_BASIC_AUTH_ACTIVE: "true" // turn Basic Auth on
N8N_BASIC_AUTH_USER: "admin" // login username
N8N_BASIC_AUTH_PASSWORD: "myPassword" // login password
ports:
- "5678:5678"
After restarting:
Running n8n without Basic Auth on a public URL is unsafe. Bots and scanners will find the endpoint within hours and hammer it. Basic Auth is the minimum layer of protection you should always enable before exposing n8n to the internet. It’s lightweight, built-in, and doesn’t interfere with workflows or operations.
This setup keeps your instance protected while staying simple, predictable, and fully supported by n8n.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.