How to reset .n8n user folder due to corrupted files?

  1. Is there a way to reset .n8n user folder? My database.sqlite file is corrputed. Folder does not get recreated when npm run build or dev :frowning: ?
  2. Also If I want to run multiple versions of n8n locally can I maintain distinct user folders perhaps by changing USER_SETTINGS_SUBFOLDER in packages/core/src/Constants.ts for secondary n8n versions?

Note: Currenty getting this error - SQLITE_READONLY: attempt to write a readonly database.

This occurs despite having write permissions:

ls -l database.sqlite
-rwxrwxrwx 1 gowtham gowtham 155648 Jun 1 15:52 database.sqlite
:frowning:

Hey @Gowthaman_Prabhu, are you already running multiple instances of n8n or have the database file open in another application? SQLite doesn’t support this.

If you simply want to start over with a fresh database you can simply stop n8n, delete or rename the database.sqlite file, then start n8n again.

1 Like

Hi @MutedJam. I am only running one instance of n8n now. I deleted database.sqlite file and restarted the app. I see the file has been recreated but still get the same error: SQLITE_READONLY: attempt to write a readonly database.

Okay, that sounds odd. How are you running n8n?

@MutedJam npm run dev. The problems started after I cut paste .n8n. Its back where it should but I have broken something.

Just out of curiosity, can you access the database when running n8n through any other method? For example using docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n?

@MutedJam It works with the above docker. Interestingly both docker instance and non-docker localhost:8080 work without the sqlite error when the above container process is running.

Does docker version has its own sqlite file? Is it located within the container?

Hey @Gowthaman_Prabhu, this command (or rather the -v ~/.n8n:/home/node/.n8n option of it) would mount the .n8n folder of your home directory folder into the docker container.

So the docker version would still access the database inside your ~/.n8n directory.

Interestingly both docker instance and non-docker localhost:8080 work without the sqlite error when the above container process is running

So you’re saying while the docker container is running, npm run dev works? And once the docker container stops npm run dev fails again? :exploding_head:

@MutedJam ~/.n8n:/home/node/.n8n should have been ~/.n8n:/home/gowtham/.n8n

The container instance is not using my .n8n db. It is also evident since all prior session data (Workflows, credentials) are cleared.

The container is using its own…maybe… it created one at ~/.n8n:/home/node/.n8n ?

Unable to ssh into container to verify as CMD is null.

So you’re saying while the docker container is running, npm run dev works? And once the docker container stops npm run dev fails again? — Thats correct !

@MutedJam It does not accept my local configs. Despite correcting the path to /home/gowtham/.n8n it still reports that:
UserSettings were generated and saved to: /home/node/.n8n/config.

I am sure its within the container…

I will build my container as a workaround. Finally restarting computer fixed write lock issue for local run. Thanks…