In this guide, we’ll walk you through the process of hosting n8n, a powerful open-source workflow automation tool, on Hugging Face Spaces for free, using Supabase as the database. This setup leverages the generous free tiers of both platforms to create a cost-effective, self-hosted automation hub with a public HTTPS domain. Whether you’re automating workflows, integrating AI models, or syncing data across apps, this solution offers full control, scalability, and zero startup costs. Let’s dive in!
Why Host n8n on Hugging Face with Supabase?
-
Zero-Cost Startup: Both Hugging Face Spaces and Supabase offer free tiers sufficient for small-scale n8n deployments.
-
Public HTTPS Domain: Hugging Face provides a free, user-friendly URL (e.g., your-username-your-space-name.hf.space) with automatic HTTPS.
-
Data Persistence: Supabase’s PostgreSQL database ensures your n8n workflows and credentials are stored persistently, even if the Hugging Face container restarts.
-
Scalability and Flexibility: Easily scale or customize your setup while maintaining complete data ownership.
-
AI Integration: Combine n8n’s automation capabilities with Hugging Face’s AI models and Supabase’s vector storage for advanced workflows.
This tutorial is designed for beginners and intermediate users, requiring minimal deployment experience. Follow these steps to get your n8n instance up and running in about 10-15 minutes.
Prerequisites
Before starting, ensure you have:
-
A free Hugging Face account.
-
A free Supabase account.
-
Basic familiarity with Docker and environment variables (don’t worry, we’ll guide you!).
Step-by-Step Guide to Hosting n8n on Hugging Face with Supabase
Step 1: Set Up a Supabase Project
Supabase provides a robust PostgreSQL database with a generous free tier, perfect for storing n8n’s workflows and credentials.
-
Create a Supabase Account:
-
Sign up at supabase.com/dashboard/sign-up.
-
Log in and create a new organisation.
- Create a new project. Save the database password securely, as you’ll need it later.
-
Navigate to your project’s dashboard.
-
Click the Connect button in the top left navigation bar.
Get Database Connection DetailsLocate the Transaction Pooler section.
-
-
These will be used to configure n8n’s database connection.
Step 2: Create a Hugging Face Space
Hugging Face Spaces offers a free container hosting environment with 16GB RAM, 2 CPU cores, and a public HTTPS URL, ideal for running n8n.
-
Sign Up for Hugging Face:
-
Create a free account at huggingface.co/join.
-
Choose a profile name (e.g., your-username), which will be part of your Space URL.
-
-
Duplicate an n8n Space Template:
-
search “n8n” in spaces, visit an existing n8n Space template
-
Click the three dots in the top right corner and select Duplicate this Space.
-
This creates a new Space under your account, pre-configured with n8n’s Dockerfile.
-
-
Configure the Space:
-
Go to your Space’s Settings tab.
-
Under Variables and Secrets, add the following environment variables in “New Secret” using the Supabase connection details from Step 1:
DB_TYPE=postgresdb DB_POSTGRESDB_HOST=<your-supabase-hostname> DB_POSTGRESDB_PORT=6543 DB_POSTGRESDB_DATABASE=postgres DB_POSTGRESDB_USER=<your-supabase-username> DB_POSTGRESDB_PASSWORD=<your-database-password> DB_POSTGRESDB_SCHEMA=public N8N_PROTOCOL=https N8N_PORT=7860 WEBHOOK_URL=https://your-username-your-space-name.hf.space N8N_HOST=your-username-your-space-name.hf.space GENERIC_TIMEZONE=America/New_York TZ=America/New_York
Replace <your-supabase-username>, <your-supabase-hostname> and <your-database-password> with your Supabase details. Set N8N_PORT=7860 as Hugging Face Spaces requires applications to listen on this port.
-
-
Deploy the Space:
-
Save the settings and let Hugging Face build and deploy the container. This may take a few minutes.
-
Once deployed, visit your Space URL (e.g., https://your-username-your-space-name.hf.space) to access the n8n interface.
-
Step 3: Configure n8n
After deployment, you’ll need to activate and configure your n8n instance.
-
Activate n8n:
-
Upon first visiting your Space URL, n8n may send an activation email. Check your inbox and follow the activation link to set up your account.
-
Log in to the n8n interface using your credentials.
-
-
Verify Database Connection:
-
Ensure n8n connects to Supabase by checking the logs in your Hugging Face Space’s Logs tab. If the database fails to initialize, double-check your environment variables for typos.
-
Common issues include incorrect DB_POSTGRESDB_HOST or DB_POSTGRESDB_PASSWORD. Ensure the transaction pooler port (6543) is used instead of the default PostgreSQL port (5432).
-
-
Set Up Workflows:
-
In the n8n interface, create your first workflow by adding nodes (e.g., Supabase, HTTP Request, or Hugging Face Inference).
-
Test the workflow to confirm data flows correctly to and from Supabase.
-
Step 4: Troubleshooting and Optimization
-
Hibernation: Hugging Face Spaces may hibernate after prolonged inactivity, but Supabase ensures data persistence. Restart the Space manually if needed.
-
Security Headers: n8n uses helmet with X-Frame-Options: sameorigin, which may cause issues in Hugging Face’s iframe. If the interface doesn’t load, check the browser console for errors and consider disabling strict security headers in a custom n8n configuration.
-
Backups: Regularly export workflows as JSON files for backup, as Hugging Face’s free tier storage is not persistent.
-
Performance: The free tier (16GB RAM, 2 CPU cores) is sufficient for small workflows. For larger workloads, consider upgrading to a paid Hugging Face plan or optimizing your Supabase database.
Step 5: Enhancing Your Setup with AI and Automation
-
Integrate Hugging Face Models: Use n8n’s HTTP Request node to call Hugging Face’s Inference API for tasks like text generation or sentiment analysis. Authenticate with a Hugging Face access token (read role) to avoid rate limits.
-
Leverage Supabase for AI: Store embeddings in Supabase using pgvector for AI-driven workflows, such as semantic search or chatbot applications.
-
Example Workflow: Create a workflow that pulls data from an API, processes it with a Hugging Face model (e.g., gte-small for embeddings), stores results in Supabase, and sends notifications via Slack.
FAQs
Q: Can I use this setup for production?
A: The free tiers are suitable for personal or small-scale projects. For production, consider paid plans for better reliability and performance.
Q: Why use Supabase instead of SQLite?
A: Supabase’s PostgreSQL database ensures data persistence, unlike SQLite, which may lose data on container restarts in Hugging Face’s free tier.
Q: How do I scale this setup?
A: Upgrade to Hugging Face’s paid Spaces or Supabase’s Pro tier for more resources. You can also deploy n8n on AWS Fargate for a production-grade setup.
Conclusion
Hosting n8n on Hugging Face Spaces with a Supabase database is a powerful, cost-free way to build and automate workflows. By following this guide, you can set up a fully functional n8n instance in minutes, with a public HTTPS domain and persistent storage. Whether you’re automating data syncs, integrating AI models, or building complex workflows, this setup offers flexibility and control. Start experimenting today, and share your automation ideas in the comments below!
For more details, check out the n8n documentation, Hugging Face Spaces guide, or Supabase docs.