Introduction
n8n is a powerful, fair-code, and open-source workflow automation tool that allows users to connect apps, databases, and AI services to automate tasks using a visual node-based editor. It is highly flexible, supporting self-hosting for data privacy, or a cloud-hosted version, acting as a technical, low-code alternative to similar tools like Zapier or Make.
Let's jump straight into setting the whole thing up.
1. Set up your Supabase database
Supabase will store all your workflows, credentials, and execution history so you don't lose them if the host crashes or restarts.
- Create a free account at Supabase.
- Create a New Project: Give it a name and set a strong database password. Save this password somewhere safe; you cannot see it again.
- Get Connection details:
- Once the project is ready, go to Project Overview > Click on the Connect button in the navbar or your Supabase database link. A dialog will pop up.
- Choose "Connection String" and change the method to "Transaction Pooler" (this is optional, but recommended for better performance).
- Click on "View Parameters" and copy the Host, Port (usually 6543), Database (usually postgres) and User (usually postgres.your_id).
2. Deploy n8n on Hugging Face Spaces
Hugging Face Spaces provides a free containerized environment that stays awake as long as it is used. This makes it a great platform for hosting n8n.
- Create a free account at Hugging Face.
- Navigate to Spaces and search for "n8n".
- Click on the first space that pops up. You should now be seeing the sign in screen of n8n.
- In the top right corner, near your profile picture, click on the three dots and select "Duplicate this Space".
- In the dialog that pops up, give your space a name (e.g. "my-n8n"), and choose "CPU Basic" as hardware.
- Now to set up the variables and secrets:
- Use a long, random string for N8N_ENCRYPTION_KEY (e.g. "my-n8n-super-secret-key-123").
- Paste in the username copied from Supabase for DB_POSTGRESDB_USER.
- Paste in the password created while setting up the database in Supabase for DB_POSTGRESDB_PASSWORD.
- Change GENERIC_TIMEZONE to your timezone (e.g. Europe/Berlin). Copy & paste in the same value for TZ also.
- Make sure DB_TYPE is set to "postgresdb" and DB_POSTGRESDB_SCHEMA is set to "public".
- Paste in the values you copied from Supabase; host for DB_POSTGRESDB_HOST, database for DB_POSTGRESDB_DATABASE, port for DB_POSTGRESDB_PORT.
- Leave N8N_PORT as is (usually 7860 or 5678). Make sure N8N_PROTOCOL is set to "https".
- Create a link (just type it in, no need for anything extra) in the format "https://[user-name]-[space-name].hf.space" and paste it in to both N8N_EDITOR_BASE_URL and WEBHOOK_URL. Paste in the same for N8N_HOST as well, but remember to remove the "https://" prefix.
- And finally, make sure that N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS is set to "true".
- Click on "Duplicate Space" button at the bottom. Hugging Face will now build your n8n instance/container, which takes about 2-5 minutes.
3. Finalize and Access n8n
- Once the build is complete and the status shows "Running", in a new tab, go to the n8n url you created in step 6.8.
- You should now see the n8n "Owner Setup" screen. Create your admin account with your preferred email and password.
- (Optional) Verify Persistence: Create a test workflow and save it. If you restart the Space, the workflow should still be there when you log back in, because it is stored safely in your Supabase database.
4. BONUS: Keeping n8n "Awake"
Free Hugging Face Spaces may "sleep" after some time (usually 48 hours) of inactivity. You can use a free Cron service like Cron-job.org to ping your n8n instance every few minutes to keep it active.
FYI: I set it to run every hour.