How to Self-Host n8n on a Raspberry Pi (Automation Made Simple)

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

My Raspberry Pi typically runs multiple nested scripts, each executing a different task, and I manage them manually via the command-line interface (CLI). However, this method can become quite tedious, and troubleshooting issues can be challenging. Recently, I discovered n8n, a graphical workflow automation tool, which I’ll show you how to use today.

n8n is an open-source automation tool that lets users build workflows visually rather than writing code. It can be fully self-hosted on a Raspberry Pi to automate tasks, run scripts, and expose APIs.

In this guide, I’ll explain what n8n is and how to incorporate it into your workflow. Then, I’ll guide you on how to install it and give examples of the powerful things n8n can do for you.

If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!

What is n8n and Why It Fits a Raspberry Pi

n8n is a workflow automation tool. This means, in a nutshell, it provides a graphical environment for tracing a workflow composed of sequential, logical steps. Here, each step corresponds to a specific task.

Suppose you want to create a form input where users can enter information, take that data and input it into a PDF, and save it to the cloud. This would typically require you to develop a custom script that will interact with all the different APIs.

However, using n8n, you can break these steps down into individual tasks/steps. Configure these steps in a GUI, then connect them according to the logical flow you want to achieve.

n8n comes pre-packaged with a plethora of Apps and API integrations that can be used as individual nodes (steps or tasks) in your workflow.

The key advantage of n8n is that it lets you set up your environment without manual coding; everything is done through a drag-and-drop dashboard accessible over LAN or the network.

There are two ways to run n8n:

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In
  • Cloud-Hosted: The software is hosted on n8n’s servers. You can access it through an internet connection from anywhere. However, it has paid subscription plans that determine the number of workflow executions supported.
  • Self-Hosted: The software is hosted on your own server, e.g., Raspberry Pi. You can access the dashboard through the LAN. An unlimited number of workflow executions are available, and you don’t need to subscribe to any plan.

In this article, we will primarily focus on the self-hosted version. We will run n8n on our Raspberry Pi and access it over the local network.

A Raspberry Pi is often used as an always-on machine, quietly running scripts, cron jobs, and small background tasks. n8n fits this role perfectly: it runs in the background, waits for triggers, and doesn’t need powerful hardware to work reliably.

By running n8n directly on the Raspberry Pi, you get a single, visual place to manage automations that would otherwise be scattered across scripts and schedules.

How to Install n8n on Raspberry Pi

Having understood what n8n is, we are ready to start the installation process.
n8n is easy to install: it’s available as a Docker image, and you can run it with Docker Compose.

What You Need for n8n on Raspberry Pi

Before installing n8n, we need to make sure we have the following prerequisites:

  • Raspberry Pi: n8n doesn’t require a lot of system resources at idle and can run on any version of Raspberry Pi, but the workloads you run determine what you need — more complex workflows, heavy data processing, or added services (e.g., local databases) will benefit from additional RAM and CPU headroom.

    Therefore, I recommend at least a Raspberry Pi 4 with 4GB or more RAM, or ideally a Raspberry Pi 5 for this project. If you are looking to purchase a new Raspberry Pi, you should check out recommendations for all the gear.
  • Raspberry Pi OS Installed: Before installing n8n, ensure Raspberry Pi OS is installed on your Raspberry Pi. You can use any version of Raspberry Pi OS, but I think Raspberry Pi OS Lite (64-bit) is the best choice for this project.
  • Docker/Docker Compose Installed: The easiest way to install n8n on a Raspberry Pi is via its Docker image. To run it, we need to ensure Docker and Docker Compose are up and running on our Raspberry Pi. If you are new to Docker, check out this detailed guide on how to set up Docker on your Raspberry Pi. Also consult this guide on Docker Compose.
  • System updates: Make sure your Raspberry Pi OS is up to date.

Once you have all these things set up, you can continue with the n8n installation.

Installing n8n

Here’s how to install n8n via its Docker image:

  • Make sure Docker and Docker Compose are installed and configured correctly:
    docker --version
  • Create an n8n folder and navigate inside it:
    mkdir ~/n8n
    cd ~/n8n
  • Create a Docker Compose file:
    nano compose.yaml
  • Paste in the following lines (the indentation matters!):
services:
  n8n:
    image: n8nio/n8n
  container_name: n8n
  ports:
    - "5678:5678"
  volumes:
    - ./n8n_data:/home/node/.n8n
  restart: unless-stopped
  • Save & exit (CTRL+X).
  • Run n8n by bringing the container online:
    docker compose up -d

You can check that n8n container is running properly with this command:
docker ps

And that’s it—n8n is now installed on your Raspberry Pi and running correctly. You can access n8n from any computer that’s on the same LAN as your Raspberry Pi by browsing to:
http://<Your Hostname>:5678

Quick note: If you find it hard to remember all these commands, I’ve put them all on a one-page cheat sheet. You can download it for free here so you have it handy whenever you're working on a project.

HTTP vs HTTPS

When you first open the n8n web interface, you might see a warning about secure cookies. This happens because n8n uses cookies for authentication, and by default, those cookies are marked as secure, meaning they are sent only over HTTPS.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

If you access n8n using plain HTTP, for example: http://<raspberry-pi-ip>:5678 the browser refuses to use them. This is not an error, and it does not mean your installation is broken. It’s simply n8n being cautious by default.

If you are running n8n only on your local network, the easiest solution is to disable secure cookies. This allows you to keep using HTTP without any extra setup. For a home lab or weekend Raspberry Pi project, this is usually fine as long as your network is trusted.

You can do this by adding this line to your compose.yaml file:

environment:
  - N8N_SECURE_COOKIE=false

If you plan to access n8n regularly from other devices, or if there’s any chance you’ll expose it outside your LAN, the recommended solution is to put n8n behind HTTPS.

This is typically done using a reverse proxy such as Nginx or Caddy, which handles TLS while n8n continues to run on its default port internally.

In short: HTTP with secure cookies disabled is fine for local use, but HTTPS is the proper setup for anything beyond that.

First Steps in the n8n Interface

Now that everything is installed, let’s visit the n8n web interface. From a web browser on a PC that’s on the same network as your Raspberry Pi, visit this link:
http://<Your Hostname>:5678

When you first access the n8n interface through your web browser, you will be greeted with this signup screen:

Enter your credentials here to create an n8n account. This will be a completely local account, and n8n will not initiate any form of email verification. You can enter any dummy email here as well if you plan to use it locally only.

But make sure you remember the email and password you entered here, as they will be used as login credentials for your local n8n server.

Once you have signed up and logged in, you will see a few customization options. You can select them as you prefer or skip them. Once you are done with them, you will see this dashboard:

You can create your first workflow by clicking on either the Start from scratch option displayed or on the + icon in the top left of the dashboard.

The workflow design window is straightforward and intuitive.

You can add nodes to your workflow by clicking the + icon in the top-right corner of the worksheet.

Nodes are divided into multiple categories. You can click any category to see the available apps or APIs in that category.

In n8n, workflows are primarily designed by creating nodes and connecting them in a specific structure. To understand n8n’s capabilities, we first need to know which nodes are available.

Useful n8n Nodes for Raspberry Pi Users

There are over 300 nodes that come prepackaged with a fresh n8n install. However, you can also install a plethora of community nodes. In this section, we will discuss a few nodes that serve as the fundamental building blocks to demonstrate n8n’s capabilities.

Cron Trigger/ Schedule Trigger

The schedule trigger node in n8n (formerly called the cron trigger) executes the workflow at a scheduled interval. It uses cron scheduling in the background.

You can insert it by adding the On a Schedule option from the node picker.

You can schedule the periodicity for this trigger using the drop-down boxes, or enter the schedule in cron syntax by selecting the Custom option from the Trigger Interval drop-down.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Schedule Trigger node is typically used as the starting point of your workflow. It defines the regular intervals at which the remaining blocks in your workflow will be executed. For example, in the workflow above, we have set it up to send an email to an ID at regular intervals.

Execute Command / Execute Script

The execute command node can run any bash commands in your workflow. This node, when triggered, executes the programmed command on the host machine.

This node is disabled by default. If you want to enable it, you need to add this line to the environment section of your compose.yaml file:
NODES_EXCLUDE=[]

Once you have added this line and restarted n8n, you will be able to add the Execute Command node from the Node Picker (available in the Core Nodes).

This node allows you to define sequential commands to be executed on the host machine. Keep in mind that, since we are running this inside a Docker image, the host machine is the Docker image, not our Raspberry Pi OS.

This node usually appears at the middle or end of your workflow and typically requires an input trigger to begin execution. For example, in the workflow above, we have implemented something analogous to a scheduled script that runs at regular intervals.

Webhook

Another trigger node you can use is the webhook node in n8n. Webhook node allows an external program or script to trigger a workflow by sending an HTTP request.

You can find the webhook node in the core category of the node picker.

You can define the HTTP method and path for this webhook.

You can then connect the webhook node’s output to any execution task, and that task will run whenever an HTTP request is received for the path defined in the webhook.

Webhooks are among the most useful nodes and are usually the starting point for many of your workflows. This node can be used to receive execution signals on different stimuli, such as a sensor reading, a button press, or a script execution finished.

MQTT

Another useful node, integral to any IoT-related project, is MQTT. n8n has two MQTT nodes: one is the MQTT Trigger, and the other is named just MQTT.

The MQTT Trigger node acts as the starting point of your workflow. Whenever it receives a message on the defined topic, it starts the flow and forwards it as its output (to the next node).

Similarly, the MQTT node receives input from the previous node, wraps it in an MQTT message, and sends it to the specified topic.

When combined, these two nodes allow you to create an MQTT client that can communicate with other clients through an MQTT broker, such as Mosquitto running on your Raspberry Pi.

HTTP Request

While n8n has a lot of nodes for specific APIs, if you want more control over all your HTTP requests, you can use the dedicated HTTP Request node.

You can find this node in the core nodes in the node picker as well.

You can define the Method, URL, and other parameters of the HTTP request through the settings menu of this node.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Most of the time, if a dedicated web API node is available, I recommend using it. However, if no such node is available or you are working directly with a REST API, this node will form the backbone of your workflow.

AI Agent / OpenAI node

While n8n is a flexible, self-hosted automation tool that can be used for many tasks, AI-driven workflows are a growing and visible use case for n8n. This is mostly because of the plethora of AI-based nodes available in n8n.

The most basic AI node available in n8n is the AI Agent node. This node allows you to connect to any AI model, such as OpenAI, Gemini, or DeepSeek.

Besides choosing from any of the AI models, you can also select a database solution for chat memory.

Besides using this generic node, you can also opt to choose one of the dedicated nodes for a specific AI tool. These nodes offer a plethora of options, including text, image, and audio actions.

You can also equip whatever AI model you are using with multiple tools. These tools in n8n are like weapons or equipment that you equip your AI model with. Based on the text prompt or task at hand, the AI model can use any available tools to obtain additional data.

For example, in the above example, we have equipped our OpenAI node with an HTTP Request tool and connected it to a completely different workflow.

Keep in mind that you will need login credentials, such as API keys, to access AI tools like OpenAI or Gemini. Alternatively, you can choose to run an LLM locally on your Raspberry Pi using tools like Ollama.

The AI Agent node and other similar AI nodes are extremely useful and very well fleshed out. They are easy and intuitive to use, without requiring an understanding of the inner workings of each node and tool.

Simple Project Ideas

n8n is an extremely versatile tool. It is not limited to a single use case and can be used as a graphical programming tool to create workflows ranging from low-complexity tasks, such as scheduling scripts, to higher-complexity tasks that involve AI in decision-making.

In this section, I will provide practical ideas for what you can accomplish with n8n.

Visual Replacement for Cron Jobs

Complexity: Low

A simple and practical first project with n8n is to replace traditional cron jobs with a visual workflow. On a Raspberry Pi, it’s common to rely on crontab entries to run scripts at fixed intervals, but over time these schedules become hard to track and even harder to modify.

n8n offers a cleaner alternative by combining the schedule and the action into a single, visible workflow.

Using the Schedule Trigger node, you define when the workflow should run using either simple drop-down options or a familiar cron expression. This node serves as the workflow’s starting point and eliminates the need to manually edit crontab files.

The actual task is handled by an Execute Command node, which runs a shell command or script when the schedule fires. While the command runs inside the Docker container, this setup works well for scripts or utilities that don’t need direct access to the host system.

The key benefit here isn’t raw power, but organization and traceability.

Compared to traditional cron jobs, this approach makes it much easier to understand what’s running, when it runs, and whether it succeeded. For anyone already using a Raspberry Pi to run scheduled scripts, this project alone can justify introducing n8n into the setup.

Event-Driven Automation With Webhooks or MQTT

Complexity: Medium

A practical next step after scheduled tasks is reacting to something that just happened. For example, imagine a script on your Raspberry Pi that finishes a long-running job, such as a backup or data sync.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Traditionally, you might check logs later or rely on the script itself to send a notification. With n8n, you can move that responsibility into a workflow.

In this setup, the script sends a simple HTTP request to an n8n Webhook when it finishes. That single request is enough to trigger a workflow instantly. n8n receives the signal, along with any data the script includes, and treats it as the starting point of the automation.

From there, the workflow can decide what to do next. It might log the result, send a notification only if the script failed, or forward the data to another service. All of this logic lives in a single, visible place rather than being hard-coded into the script itself.

This approach keeps scripts small and focused on doing one job well, while n8n handles coordination and follow-up actions. Once you get used to this pattern, it becomes an easy way to connect otherwise isolated tasks without constantly polling or adding more code.

Intelligent Filtering and Decision-Making With AI

Complexity: High

A more advanced use of n8n is to turn your Raspberry Pi into a small, self-aware system that can answer questions about its own health. Instead of checking dashboards or running commands manually, you can ask the system how it’s doing and receive a concise, meaningful response.

In this setup, the Raspberry Pi exposes its hardware statistics through a simple HTTP endpoint. This endpoint returns current information such as CPU usage, memory consumption, disk space, or temperature.

n8n retrieves these values when needed and uses them as the factual basis for any decision or response.

An incoming query—sent over MQTT or another messaging channel—triggers the workflow. The AI node evaluates the request, gathers the latest system statistics via an HTTP request, and then summarizes the system’s state in plain language.

Rather than returning raw numbers, it provides context, such as whether the system looks healthy or if something might require attention.

This approach highlights where AI naturally fits into a home automation setup. The Raspberry Pi and n8n handle data collection and orchestration, while the AI helps interpret that data in a way that’s easier to understand and act upon.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Want to connect with other Raspberry Pi fans? Join the RaspberryTips Community. Ask questions, share your projects, and learn from each other. Join now.

FAQ and Practical Tips

Does n8n run all workflows continuously?

No. n8n stays idle most of the time and only executes a workflow when a trigger fires. This can be a schedule, a webhook, an MQTT message, or another event. This event-driven behavior makes it well-suited for an always-on Raspberry Pi without constantly consuming CPU or memory.

Is it safe to disable secure cookies when using HTTP?

Disabling secure cookies is acceptable if n8n is only accessible from a trusted local network. For home lab setups where the Raspberry Pi is not exposed to the internet, this is a reasonable trade-off for simplicity. If you plan to access n8n remotely or expose it publicly, using HTTPS via a reverse proxy is strongly recommended.

Does the Execute Command node run on the Raspberry Pi itself?

When n8n runs in Docker, the Execute Command node runs commands within the container, not directly on the Raspberry Pi OS. This is fine for container-based tools or scripts, but it’s important to understand the execution context. If you need direct access to the host system, additional configuration is required.

Does my Raspberry Pi need to stay powered on?

Yes. Since n8n waits for triggers, the Raspberry Pi needs to remain powered on for workflows to run automatically. In practice, this is no different from running cron jobs, MQTT brokers, or other background services, and the power consumption remains low.

Can I migrate existing scripts into n8n?

Yes, and you don’t need to do it all at once. Existing scripts can be triggered using schedules, webhooks, or MQTT messages, allowing you to gradually move orchestration logic into n8n while keeping your existing tools intact.

I have saved my workflow, but why isn’t it being triggered?

For your workflow to get triggered, you must publish it first. You can do this by clicking the Publish button next to the Save button.

n8n works well on a Raspberry Pi because it brings structure and visibility to tasks that are often scattered across scripts and schedules. It runs quietly in the background, waiting for triggers, while giving you a clear view of what’s happening and why.

You can start with simple automations and gradually build more advanced workflows as your needs grow, all while keeping everything local and under your control. For anyone who enjoys automation but wants fewer scripts and more clarity, n8n is a natural fit.

Whenever you’re ready, here are other ways I can help you:

Test Your Raspberry Pi Level (Free): Not sure why everything takes so long on your Raspberry Pi? Take this free 3-minute assessment and see what’s causing the problems.

The RaspberryTips Community: Need help or want to discuss your Raspberry Pi projects with others who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct help.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts