How to flush credentials with old encryption key?

  • n8n version: 1.75.2
  • **Database (default: SQLite): ** PSQL
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): ** own
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): ** docker in portainer
  • Operating system: Ubuntu 22

Hi,
I’ve been running n8n for a few years, but recently redeployed it in a portainer cluster (docker swarm).
I thought it was persisting the local data, as I had that set in the .env file as DATA_FOLDER=/root/n8n with an accompanying shared filesystem mount.

But it turns out that wasn’t working properly, as according to the logs the deployment has been trying to use “/home/node”, which only existed in the container.
This also explains why the credentials have been complaining about a “different encryption key” every time I update…
I’ve fixed the mount issues, which now has properly created the .n8n/config file and other directories in persistent storage.
However, the credentials screen in the gui is not fully loading, for some reason (see image).

I’ve managed to export the workflows and credentials to json files using the cli, so they’re safe.
I also tried to delete all credentials based on this How to delete all credentials & workflows - #2 by n8n
but “n8n delete:credentials --all” doesn’t work? (or even for a single one with specifying the id)
What’s going to be the best way to flush this out? (without reinstalling/redeploying)

Thanks,

Sean.

Could this be related to that topic ?

easiest is to go into the database and truncate the credentials_entity table.

It does look very similar to that.
I’ve even got some workflows/credentials id’s that are just numbers instead of strings.

With postgres, that seems like a bad idea?
Would it work if I just delete the entries individually? (there are only 11)
unless the cascade just deletes the matching id in another table?

" TRUNCATE cannot be used on a table that has foreign-key references from other tables, unless all such tables are also truncated in the same command."

as
n8n=# \d credentials_entity;
Table “public.credentials_entity”
Column | Type | Collation | Nullable | Default
-----------±----------------------------±----------±---------±---------------------
name | character varying(128) | | not null |
data | text | | not null |
type | character varying(128) | | not null |
createdAt | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP(3)
updatedAt | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP(3)
id | character varying(36) | | not null |
isManaged | boolean | | not null | false
Indexes:
“credentials_entity_pkey” PRIMARY KEY, btree (id)
“pk_credentials_entity_id” UNIQUE, btree (id)
“idx_07fde106c0b471d8cc80a64fc8” btree (type)
Referenced by:
TABLE “shared_credentials” CONSTRAINT “FK_416f66fc846c7c442970c094ccf” FOREIGN KEY (“credentialsId”) REFERENCES credentials_entity(id) ON DELETE CASCADE

You asked how to delete them all. So yeah truncate cascade would work.
But looking at the other topic it seems you only need to delete the credentials with a numeric ID. so better do do that than so you can save some of the credentials.

OK, I deleted the credentials one at a time from postgres, starting with the oldest.
I ended up removing all except the test one I created earlier today.
The credentials screen is now showing up properly.
Thanks for the help!

1 Like

Hey there, I managed to fix my issue with these steps. Hope it helps !

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