Rest and api

Hi there,

After a period of reflection, I started to pick up n8n again. First of all my compliments to the n8n team: it looks like you haven’t been just spinning thumbs for the last half year!

I also noticed, that since desktop app v 1.4.0 (n8n 0.174.0) my backup is no longer working. My backup workflow was basis on localhost:5679/rest/workflows and …/rest/credentials. Unfortunately, this no longer works, as instead of the json data, I’m now getting ‘Unauthorized’. I’ve tried via basic authentication, but that does not work either.

Does anybody know how to fix this?

And yes, I know that there is now a public API, and of course I want to upgrade to this method, but for now, I’ve got two reasons to get the existing workflow up and running:

  1. I want to get my backup system up and running asap

  2. I want to be able to backup my credentials, which (as far as I can see now) is not possible via the api

Thanks in advance and best regards, Dick

P.s.: my current backup workflow:

1 Like

Hi @dickhoning, good to see you again. The authentication options have changed a bit and with these endpoints intended for internal use there is no official documentation. However, @pemontto shared a great example of how to authenticate against the internal API which should help you get started:

Let me know if you run into any trouble with this.

Hi @MutedJam , thanks for pointing this out to me. Unfortunately, I can not get @pemontto 's solution to work. Keep getting error 401. Since the REST functionality is undocumented, I’m probably going to rebuild my backup routine with n8n’s API. The only question remaining, is how can I backup my credentials? Or is there perhaps a simple solution to backup the relevant SQL tables? Thanks again!

Hey @dickhoning,

You could use the CLI option to backup your workflows and credentials and trigger that with an execute command node.

Hi @Jon thanks! Just gave it a spin, and this is what I’m getting:

[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n export:workflow --backup --output=/Users/dick/Temp/n8n/Backups
Error exporting workflows. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save

Any idea to what I might be doing wrong?

Thanks in advance and best regards Dick

Hey @dickhoning,

That is a bit odd and mildly annoying, I suspect I have not ran into that one before because I have that package installed I will need to do some testing on that one. I guess if you have npm installed doing an npm install sqlite3 -g would probably solve the issue but it should really work.

Hi Jon, thanks for looking into this for me. In the meantime, I looked at the rest option again. When I try the following in a webbrowser, it works fine, as follows:

  1. go to http://localhost:5678/signin
  2. sign in
  3. http://localhost:5678/workflow now returns the data as before (/in the old version of n8n

Now I’m just wondering how to reproduce this behaviour in n8n. I looked at Credential unauthorized - #3 by pemontto but can not get this to work. Not in the latest version of the n8n desktop app, nor in Postman …

Hey @dickhoning,

What happens if you run each node one at a time? That would tell us which one is having a problem.

@Jon the Get n8n JWT node …

Hey @dickhoning,

Change the Request Method to Get and see if that works.

@Jon just did, same error …

Are you using user management as well? That also changes things

@Jon I’ve been playing around with Users, but do not really need is. How can I disable/get rid of this?

Hey @dickhoning,

You can disable it by setting N8N_USER_MANAGEMENT_DISABLED to true in the desktop env file, On Mac it will be ~/.n8n/n8n-desktop.env, Then once set run the n8n user-management:reset command to reset it.

You can also send the login request in that first node if needed so you would do a post request to /rest/login and send a body that contains 2 fields email and password the second node from the other workflow would then work with the same output.

The downside to this one though would be you would have those credentials in the workflow so you would need to make sure you exclude that workflow from your backup.

Hi @Jon thanks again for trying to help me on this one. I followed your instructions, but now run into an error trying to reset user management via the command line. I then installed sqlite3, but still keep getting the same error …

Last login: Sat Nov  5 08:07:18 on ttys002
[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n user-management:reset
Error resetting database. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save
[email protected] ~ % npm install sqlite3 -g                                                                     
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs

changed 104 packages, and audited 105 packages in 3s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n user-management:reset
Error resetting database. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save
[email protected] ~ % 
[email protected] ~ % sqlite3 --version
3.37.0 2021-12-09 01:34:53 9ff244ce0739f8ee52a3e9671adb4ee54c83c640b02e3f9d185fd2f9a179aapl
[email protected] ~ % 

Hi @dickhoning, tbh I think at this stage it would make sense to switch to a different deployment method.

I am not very familiar with MacOS, so I can’t really say why sqlite3 is acting up on your machine. You shouldn’t have this problem with docker though as the pre-built n8n image includes everything needed to run n8n.

Assuming you have Docker installed, running n8n would be as simple as executing the below command in your terminal:

docker run -it --rm --name n8n -p 5678:5678 -d -v ~/.n8n:/home/node/.n8n n8nio/n8n:0.201.0

All dependencies would live inside the n8n container, so you wouldn’t have to worry about them.

@MutedJam thanks for your suggestion. I actually prefer to use n8n both via Docker as well as via the App. The App gives me the possibility to create workflows that act on macOS.


As to starting my Docker container of n8n, is use the following code:

docker run -it --restart unless-stopped \
	--name n8n \
	-p 5678:5678 \
	-v ~/.n8nDocker:/home/node/.n8n \
	n8nio/n8n

I use a different folder (~/.n8nDocker) so that the Desktop App and Docker container each have their own database/workflows.

The option --restart unless stopped together with ‘Start Docker Desktop when you log in’ makes sure that n8n is always running, even if the macOS restarts after power failure.


An example of Desktop App specific workflows that I've got running for one of my customers:

… checks if a server volume is mounted, and if not mounts it …

… gets files from externally stored containers on a FileMaker Servers and move them to the corresponding project folders on a file server …

You can use the webhook tunnel with the docker version of n8n as well, check out the docs for an example. This would use the same tunnel mechanism also used by the desktop app (so nothing we’d recommend for production use cases).

Reading/writing binary files also works through docker, but requires that you make your local directory available as a volume inside the docker container. The command shared above already does this for your local ~/.n8n directory. By using the -v ~/.n8n:/home/node/.n8n option, the local ~/.n8n directory becomes available inside the n8n container as /home/node/.n8n. This allows the docker version of n8n to read the local n8n database and access the same workflows as the desktop app (or an npm deployment).

You can add more directories as needed by adding multiple -v parameters. For example, if you wanted to make your local directory ~/customer_files available inside the n8n container as /files, you could add -v ~/customer_files:/files to your docker run command.

Thanks @MutedJam ! I’m going to look into this, but the first thing I noticed in de docs is this:

This restriction would also apply to the desktop app though. The tunnel server is something we provide free of charge and doesn’t come with any uptime or availability guarantees. For a production solution you’d want to host n8n on a webserver with a static domain name.