Encryption Key Question

Questions on saving the encryption key.

So when i updated last time, I had an issue with the encryption key being changed and I had to enter the credentials again. Didnt know I had to save things or copy key before I upgraded. Now i see there is a new version available and want to make sure I do things correctly this time.

I recently did the n8n setup a while back and don’t remember how I did it and what instructions i followed to do the setup.

I just did create a new .env file as per instructions here - Docker Compose | n8n Docs

Thanks for any help or suggestions in advance…

Information on your n8n setup

  • n8n version: 1.37.3
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): No idea
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker // docker-compose
  • Operating system: Ubuntu 22.04

Hi @Vyas_Monarch

Thanks for posting here and welcome to the community! :partying_face:

If I understand you correctly, you are looking to upgrade n8n without losing your encryption key or having to re-enter your credentials, right?

n8n creates a random encryption key automatically on the first launch and saves it in the ~/.n8n folder.
I’d recommend to do the update first and then start the service with your encryption key set.

Before updating, it’s always a good idea to backup your current .env file (and any other configuration files you might have).

In your docker compose file you can set the environment variable as below:

N8N_ENCRYPTION_KEY=your_encryption_key_here

Then, you can run the following commands in the directory containing your docker-compose.yml.

docker-compose pull n8n
docker-compose up -d

This will pull the latest n8n image and restart your service with the new version, using the existing .env configuration. (-d stand for “detached mode” to run the container without blocking your terminal.)

I hope this helps and please do let us know you get on! :seedling:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.