AI Personal Learning
and practical guidance
Beanbag Marscode1

n8n Free Cloud Deployment Guide: Public Access with Hugging Face

Background: why public access is needed n8n

n8n is a powerful open source workflow automation tool that allows users to connect different applications and services to create automated processes. However, many of n8n's App nodes (especially those that involve authorization of third-party services) need to be configured with an OAuth Redirect URL during use.


This requirement means that n8n instances must be accessible over the public Internet. Further, some nodes, such as those connecting to Google services or the Twitter/X platform, may also mandate the use of public top-level domains as well as HTTPS encrypted connections.

If n8n is deployed only on a local network that does not cater to public HTTPS domain access, these node features that rely on external authentication or callbacks will not be available. This definitely limits the full potential of n8n and discounts its functionality.

Traditional solutions usually involve renting a cloud server (VPS), purchasing a domain name, configuring DNS resolution, and applying for and deploying SSL certificates. Not only is the entire process a lot of steps, but it can also incur ongoing costs.

 

Solution: Free Deployment with Hugging Face and Supabase

Fortunately, there is a free and relatively quick way to deploy an instance of the n8n cloud service that supports HTTPS and public domains in a short period of time (say 10 minutes or so). This article describes how to accomplish this using a combination of Hugging Face Spaces and Supabase.

This combined solution leverages Hugging Face Spaces to provide a free container hosting environment (with public URLs and automatic HTTPS) and Supabase to provide a free PostgreSQL database to persistently store n8n's workflow data.

Note: International Internet access may be required to perform the following steps.

 

Step 1: Configure the Supabase Database

Supabase is an open source Firebase alternative that provides back-end services such as database, authentication, and storage. Although it has paid plans, its free package provides enough resources to meet n8n's basic data storage needs.

The free package includes sufficient database space and resources (as shown below).

  1. Visit the official Supabase website: https://supabase.com/
  2. Click "Sign in" to register or log in.

  3. After successful registration, the system will guide you to create an organization. Keep the Plan as Free and click on "Create organization".

  4. Next, create a Project. Set a name for the project, set a secure password for the database (strong passwords are recommended to avoid problems that can be caused by special characters), and select a region, e.g. US West. Click "Create new project".

  5. Once the project is created, go to the project dashboard. Click the "Connect" button at the top or find "Project Settings" -> "Database" in the left navigation bar.

  6. On the Database Connection Information page, find the Connection String section. If you see a place to select Type, you can select "SQLAlchemy" (although we actually need the connection parameters below).

  7. Scroll down the page to find the detailed connection parameters for the database (host, database name, port, username, password, etc.). This information will be used later in Hugging Face. Please keep it safe, especially the password.

Step 2: Deploy n8n at Hugging Face Spaces

Hugging Face (often referred to as "Hugging Face") is a well-known AI and machine learning community platform with a Spaces feature that allows users to host web applications and Docker containers.

  1. Access the pre-configured n8n Hugging Face Space template: https://huggingface.co/spaces/fuliai/ain8n
  2. Click on the three dots in the upper right corner of the page and select "Duplicate this space".

  3. Go to the configuration page of the replica space. Here, you need to fill in the database connection information you just got from Supabase into the corresponding environment variable:
    • DB_TYPE: Set to postgresdb
    • DB_POSTGRESDB_HOST: Fill in the Host provided by Supabase.
    • DB_POSTGRESDB_PORT: Fill in the Port provided by Supabase (usually 5432).
    • DB_POSTGRESDB_DATABASE: Fill in the Database name provided by Supabase (usually postgres).
    • DB_POSTGRESDB_USER: Fill in the User provided by Supabase (usually postgres).
    • DB_POSTGRESDB_PASSWORD: Fill in the Supabase database password you set earlier.
    • DB_POSTGRESDB_SCHEMA: You can keep the default publicThe
    • N8N_HOST: This is automatically generated here, usually in the format 你的用户名-你的空间名.hf.space. Make sure that this domain name is the same as the WEBHOOK_URL The prefixes are consistent.
    • WEBHOOK_URL: Ensure that its value is https:// on top of that N8N_HOST value (e.g. https://yourname-ain8n.hf.space/).
    • GENERIC_TIMEZONE: Set the time zone as required, e.g. Asia/ShanghaiThe
    • EXECUTIONS_DATA_PRUNE: Set to true The execution log can be cleaned up automatically to save database space.
    • EXECUTIONS_DATA_MAX_AGE: If cleanup is turned on, set the number of days to retain logs, for example 14The

    Select Space visibility as Public (public access). Subsequently the n8n instance itself will set the administrator password, so there is no need to worry about unauthorized access.

    Important: Please double check N8N_HOST cap (a poem) WEBHOOK_URL The domain name portion of the Hugging Face must be consistent with the Space URL assigned to you by the Hugging Face.

  4. Once the configuration is complete, click the "Duplicate space" button in the lower left corner.

  5. Hugging Face Spaces will start building and deploying Docker containers automatically in the background.

  6. Wait for the deployment to complete. This can be done in the Logs tab to view the deployment log. When you see a log message like the one in the red box below, especially the message about n8n starting successfully, it means that the deployment has been successful (usually completed within 5 minutes). The log usually shows the version number of the n8n.

  7. Copy the n8n access address provided in the log (usually the https://yourname-ain8n.hf.space/), open it in your browser.

 

Step 3: Initialize n8n Settings

  1. The first time you access a deployed n8n address, the system will ask to set up an administrator account. Please create a secure username and password.

  2. Follow the guided steps to complete the setup. There may be a step asking if you want to get a free license key, click "Send me a free license key" or similar. This is usually to receive notifications of updates or to enable Community Edition features.

  3. Once you have completed all the settings, you can go to the main interface of the n8n and start creating and managing workflows.

This n8n instance can be found and managed by clicking on the user's avatar in the top right corner of the Hugging Face page -> select Spaces under your username.

 

Why Hugging Face + Supabase?

The main reason for choosing this option was to take advantage of the free resources available on both platforms:

  • Hugging Face Spaces: Provides a free container runtime environment, an automatically assigned public HTTPS domain name, and solves the problem of public network access and secure connections. However, a limitation of its free service is that Space may be hibernated by the system if it is inactive for a long period of time. After hibernation or reboot, the local data inside the container is lost (because Docker containers are inherently stateless).
  • Supabase: A free PostgreSQL database is provided. By configuring n8n to use an external Supabase database, all workflow, credentials, and execution data are stored in the database, not in the container. In this way, even if Hugging Face Space is hibernated or restarted, the n8n will reconnect to the Supabase database when it starts up, restoring all data and solving data persistence issues.

Nonetheless, it is still recommended to export important workflows as JSON files and back them up locally on a regular basis in case something unexpected happens.

n8n is powerful in its own right, and while it may take some time to familiarize yourself with it, you can build complex and useful automated processes once you've mastered it. It also supports exporting results to common formats such as Word and Excel, which is very convenient.

May not be reproduced without permission:Chief AI Sharing Circle " n8n Free Cloud Deployment Guide: Public Access with Hugging Face
en_USEnglish