{"id":122902,"date":"2025-02-18T13:13:27","date_gmt":"2025-02-18T13:13:27","guid":{"rendered":"\/tutorials\/?p=122902"},"modified":"2026-03-10T09:26:54","modified_gmt":"2026-03-10T09:26:54","slug":"how-to-self-host-n8n","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-self-host-n8n","title":{"rendered":"How to self-host n8n on Ubuntu"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Self-hosting n8n on an Ubuntu server offers enhanced data privacy, greater control, and efficiency than the managed, cloud hosting solution. Installing n8n also only takes a few steps if you already have a system with sufficient hardware resources that provides full root access to its terminal.<\/p><p>There are three ways to self-host n8n on Ubuntu, each with its distinct benefits and suitable for different users:<\/p><ul class=\"wp-block-list\">\n<li><span style=\"margin: 0px;padding: 0px\"><strong>Self-host n8n using<\/strong>&nbsp;<strong>Node Package Manager (npm)<\/strong>.<\/span> Download and install the n8n package through npm via your system&rsquo;s terminal. It&rsquo;s the most straightforward method, and it works for any system, but it&rsquo;s the least reliable.<\/li>\n\n\n\n<li><strong>Deploy n8n in a Docker container.<\/strong> Set up a Docker container that runs n8n. The extra steps and tools can make this method more complex, but it&rsquo;s more reliable than using <strong>npm<\/strong>.<\/li>\n\n\n\n<li><strong>Install n8n on a Hostinger VPS using a template.<\/strong> Set up n8n in a few clicks using Hostinger&rsquo;s template. Since this method doesn&rsquo;t require executing commands, it&rsquo;s the safest, easiest, and most efficient.<\/li>\n<\/ul><p>Regardless of the installation method, self-hosting n8n requires careful management as you&rsquo;ll have to handle the server administration tasks yourself. The most essential practices include keeping your n8n instance secure, updating it regularly, and setting up a robust backup system for optimal data integrity.<\/p><p>Explore how to self-host n8n on Ubuntu in more detail, including different methods to install it and the best practices after deployment to keep the automation platform secure. <\/p><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites-for-self-hosting-n8n\">Prerequisites for self-hosting n8n<\/h2><p>Since <a href=\"\/ca\/tutorials\/what-is-n8n\">n8n is<\/a> a platform that requires specific hardware resources and dependencies, you&rsquo;ll need to fulfill the following requirements before setting up self-hosting:<\/p><ul class=\"wp-block-list\">\n<li><strong>A Linux system. <\/strong>For the best performance, the host system that will run n8n should run the latest version of the Linux operating system. For this tutorial, we&rsquo;ll use Ubuntu, as it&rsquo;s the most popular.<\/li>\n\n\n\n<li><strong>Server hardware. <\/strong>Your n8n hosting environment should have at least <strong>1 GB of RAM <\/strong>and <strong>1 CPU core<\/strong>. We recommend <strong>2 GB of RAM<\/strong> and<strong> 2 CPU cores<\/strong> for headroom and future-proofing. <\/li>\n\n\n\n<li><strong>Domain for HTTPS. <\/strong>A domain is mandatory for issuing and installing SSL\/TLS on our n8n instance. This is crucial since n8n requires a secure connection by default. <\/li>\n\n\n\n<li><strong>Terminal access. <\/strong>Since installing and configuring n8n requires executing commands, you should be able to access the host environment&rsquo;s terminal as root. <\/li>\n\n\n\n<li><strong>Docker installed (recommended). <\/strong>While you can set up n8n outside a container, using Docker improves isolation and streamlines management. If you wish to deploy n8n inside a container, make sure you have <a href=\"\/ca\/tutorials\/how-to-install-docker-on-ubuntu\">installed Docker<\/a> on your system.<\/li>\n<\/ul><p>The right VPS requirements are key for stable n8n hosting. Underpowered servers can slow or fail your workflows. Check our article on <a href=\"\/ca\/tutorials\/n8n-vps-requirements\">n8n VPS requirements<\/a> to choose the best setup.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-self-host-n8n-with-npm\">How to self-host n8n with npm<\/h2><p>The most basic method of self-hosting n8n is manually installing it using commands through <strong>npm<\/strong>. This works across different systems, whether a local computer or a virtual private server, regardless of the hosting provider.<\/p><p>However, this installation method can be unreliable if you want n8n to run 24\/7 since it lacks built-in restart policies and requires a process manager to remain consistently active. It is mainly suitable if you wish to deploy n8n for testing.<\/p><p>Note that depending on your Linux distribution, the commands differ. Here&rsquo;s how to self-host n8n with npm on an Ubuntu server:<\/p><ol class=\"wp-block-list\">\n<li>Log in to your system&rsquo;s terminal as root. Use SSH if you use a remote machine like a VPS. <\/li>\n\n\n\n<li>Run the following command to update the system package and upgrade installed software to avoid potential incompatibility issues:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update &amp;&amp; sudo apt upgrade -y<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Set up a terminal multiplexer that will allow n8n to run continuously in the background. In this tutorial, we&rsquo;ll use <a href=\"\/ca\/tutorials\/how-to-install-and-use-linux-screen\">Linux Screen<\/a>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install -y screen<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Install essential dependencies &ndash; packages that n8n requires to run and function properly. Since n8n requires Node.js and npm, download their setup script using this command: <\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -fsSL https:\/\/deb.nodesource.com\/setup_22.x | sudo -E bash -<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Install <strong>Node.js<\/strong> and <strong>npm<\/strong> by running:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt-get install -y nodejs<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Verify the installations with these commands. If Node.js and npm are configured properly, your terminal will return their version number:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">node -v\nnpm -v<\/pre><p>After installing Node.js and npm. download and configure n8n:<\/p><ol class=\"wp-block-list\">\n<li>Install n8n globally using npm:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">npm install -g n8n<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Start a Screen session called <strong>n8n<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">screen -S n8n<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Run n8n inside the screen session:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">n8n<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Detach from the Screen session to return to the main terminal by hitting <strong>CTRL<\/strong>+<strong>A<\/strong> then <strong>D<\/strong>. <\/li>\n\n\n\n<li>Enter the following address in your web browser, with <strong>your-server-ip<\/strong> being your server&rsquo;s actual address:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:5678<\/pre><p>At this point, you might receive a secure cookie error. While you can bypass this, we highly recommend installing an SSL certificate to ensure n8n is secure. We&rsquo;ll cover the steps in detail later. <\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-self-host-n8n-with-docker\">How to self-host n8n with Docker<\/h2><p>Self-hosting n8n with Docker is more reliable, as using a container offers a high level of autonomy and isolation. This simplifies the management and integration, should you want to deploy other tools to the same hosting environment. <\/p><p>Note that this setup process is more complicated than using npm for new Docker users, but it&rsquo;s the recommended method given the benefits. To learn more about the steps in detail, check out our tutorial on <a href=\"\/ca\/tutorials\/how-to-self-host-n8n-with-docker\">self-deploying n8n with Docker<\/a>. <\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-self-host-n8n-using-hostinger-s-vps-template\">How to self-host n8n using Hostinger&rsquo;s VPS template<\/h2><p>You can easily <a href=\"\/ca\/self-hosted-n8n\">self-host n8n on Hostinger&rsquo;s VPS<\/a> with a few clicks using our OS template &ndash; a preconfigured solution that automatically installs and configures n8n along with its dependencies. <\/p><p>In addition to making the process easier and more efficient, using the Hostinger VPS template helps avoid errors because our system handles all the configuration tasks. Here&rsquo;s how to install n8n using our template:<\/p><ol class=\"wp-block-list\">\n<li>Go to <a href=\"http:\/\/hpanel.hostinger.com\" target=\"_blank\" rel=\"noopener\">hPanel<\/a> and log in using your preferred method.<\/li>\n\n\n\n<li>Once you&rsquo;ve logged in, navigate to the <strong>VPS<\/strong> section on the left-hand-side menu.<\/li>\n\n\n\n<li>Choose the VPS you want to apply the n8n template to and hit the <strong>Manage<\/strong> button next to it.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1d43552770\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"310\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/manage-vps-1024x310.png\" alt=\"VPS tab open on hpanel with Manage button highlighted\" class=\"wp-image-122906\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Once in the VPS dashboard, open the <strong>OS &amp; Panel<\/strong> dropdown menu on the left and select <strong>Operating System<\/strong>. This is where you can find hunderds of templates for installing different operating systems and applications on your Hostinger VPS.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1d43553ee8\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"428\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/operating-system-1024x428.png\" alt=\"Operating system window open on VPS dashboard\" class=\"wp-image-122907\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>In the <strong>Change OS<\/strong> panel, type <strong>n8n<\/strong> into the search bar and select the n8n template.<\/li>\n\n\n\n<li>In the dialogue window that opens, click or tap <strong>Change OS.<\/strong> <\/li>\n\n\n\n<li>You&rsquo;ll see a dialog window informing you that your VPS OS will be overwritten and all files will be deleted. Check the box next to &ldquo;<strong>I recognize that all my files will be deleted and cannot be restored<\/strong>&ldquo; and click <strong>Next.<\/strong><\/li>\n\n\n\n<li>Enter a password for the root user and click <strong>Confirm<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1d43555591\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1138\" height=\"644\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/Screenshot-2025-09-16-at-15.30.44.png\" alt=\"'Create new root password' screen\" class=\"wp-image-134251\"  sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Template setup will begin. You&rsquo;ll see a progress bar at the top of your dashboard, like in the example below:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1d43556a78\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"219\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/install-progress-1024x219.png\" alt=\"Progress bar for Recreate VPS action\" class=\"wp-image-122910\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p><div class=\"protip\">\n                    <h4 class=\"title\">&#128161; Pro tip<\/h4>\n                    <p>If you ever want to change your VPS password, you can do it through the <strong>Settings<\/strong> menu or by using <strong>Kodee<\/strong>, our AI-powered assistant. <strong>Kodee<\/strong> makes it easier &ndash; just type a prompt asking it to change your server's password and include the new one. For example: \"Please change my VPS password to MyNewSecurePassword123.\"<\/p>\n                <\/div>\n\n\n\n<\/p><p>Once n8n is installed, you can access it by going to hPanel&rsquo;s <strong>VPS Overview <\/strong>page and clicking <strong>Manage App.<\/strong><\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e1d43556eb7\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/hpanel-vps-overview-manage-app-highlighted-1024x552.png\" alt=\"The Manage App button in the VPS Overview page of hPanel\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Installation is the first step in self-hosting n8n, regardless of the configuration methods. You must follow several more steps to ensure it works correctly and securely.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-are-the-best-practices-for-self-hosted-n8n\">What are the best practices for self-hosted n8n?<\/h2><p>Below are several best practice recommendations for self-hosting n8n. You should follow these instructions closely to ensure your automation platform functions optimally.<\/p><h3 class=\"wp-block-heading\">1. Secure your n8n setup<\/h3><p>Since n8n contains a lot of sensitive data and credentials, it&rsquo;s crucial to secure the platform and its hosting environment. <\/p><p>If you&rsquo;re using a custom domain, install an SSL certificate to allow n8n to use the HTTPS connection. This is mandatory if you install n8n using npm or Docker, as this platform requires a secure cookie by default.<\/p><p>The easiest way to install SSL on your VPS is by using <strong>Let&rsquo;s Encrypt<\/strong> with <strong>NGINX<\/strong> as a reverse proxy. Here&rsquo;s how to do it:<\/p><ol class=\"wp-block-list\">\n<li>Install <strong>Certbot<\/strong> and <strong>NGINX<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install certbot nginx python3-certbot-nginx -y<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Create\/open the NGINX site file for n8n:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/nginx\/sites-available\/n8n<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Configure NGINX as a proxy for traffic to n8n. Add the following, replacing <strong>yourdomain.com<\/strong> below with your own custom domain name:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server {\n   server_name yourdomain.com;\n   location \/ {\n       proxy_pass http:\/\/localhost:5678;  # Forward requests to n8n\n       proxy_set_header Host $host;\n       proxy_set_header X-Real-IP $remote_addr;\n       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n       proxy_set_header X-Forwarded-Proto $scheme;\n   }\n   listen 80;\n}<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Save and close the file with <strong>CTRL<\/strong>+<strong>X<\/strong>, then <strong>Y <\/strong>and <strong>ENTER.<\/strong><\/li>\n\n\n\n<li>Enable the configuration and restart NGINX:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ln -s \/etc\/nginx\/sites-available\/n8n \/etc\/nginx\/sites-enabled\/\nsudo systemctl restart nginx<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Get an SSL certificate for your custom domain (replace <strong>yourdomain.com<\/strong> below with your custom domain name):<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo certbot --nginx -d yourdomain.com<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Let&rsquo;s Encrypt certificates expire every 90 days by default. To automatically renew it, set up a cron job on certbot:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo certbot renew<\/pre><ol start=\"8\" class=\"wp-block-list\">\n<li>Select <strong>nano<\/strong> if prompted to select a text editor.<\/li>\n\n\n\n<li>Add the following cron job:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">0 2 * * * certbot renew --quiet --post-hook \"systemctl restart nginx\"<\/pre><ol start=\"10\" class=\"wp-block-list\">\n<li>Save and close the file with <strong>CTRL<\/strong>+<strong>X<\/strong>, then <strong>Y <\/strong>and <strong>ENTER.<\/strong><\/li>\n<\/ol><p>For Docker-based installation, the steps are similar. The difference is that the NGINX configuration looks like the following:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server {\n   server_name yourdomain.com;\n   location \/ {\n       proxy_pass http:\/\/localhost:5678;  # Forward requests to n8n\n       proxy_set_header Host $host;\n       proxy_set_header X-Real-IP $remote_addr;\n       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n       proxy_set_header X-Forwarded-Proto $scheme;\n   }\n   listen 80;\n}\n<\/pre><p>Also, you need to take these additional steps after setting up the auto-renewal cron job:<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Open the <strong>docker compose.yml<\/strong> file with nano:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano ..\/root\/docker compose.yml<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Update the following environment variables:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">- WEBHOOK_URL=https:\/\/yourdomain.com\/\n- N8N_HOST=yourdomain.com\n- N8N_PORT=5678\n- N8N_PROTOCOL=https<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Save and close the file with <strong>CTRL<\/strong>+<strong>X<\/strong>, then <strong>Y <\/strong>and <strong>ENTER.<\/strong><\/li>\n\n\n\n<li>Restart Docker Compose to apply the changes<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose down<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose up -d<\/pre><p>By default, n8n doesn&rsquo;t enforce authentication, so anyone who accesses your server&rsquo;s IP can use it. To secure your instance, set environment variables before running the container.<\/p><p>With <strong>direct installation<\/strong>, you can use the export command to add variables. In the example below, be sure to replace <strong>username<\/strong>, <strong>password<\/strong>, and <strong>yourdomain.com<\/strong> with your chosen credentials:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">export N8N_BASIC_AUTH_ACTIVE=true\nexport N8N_BASIC_AUTH_USER=username\nexport N8N_BASIC_AUTH_PASSWORD=password\nexport N8N_HOST=yourdomain.com\nexport N8N_PORT=5678\nexport WEBHOOK_URL=https:\/\/yourdomain.com\/\nexport GENERIC_TIMEZONE=UTC<\/pre><p>When running n8n as a Docker container (<strong>containerized installation<\/strong>), you can pass these variables using the <strong>-e<\/strong> flag (again, add your own credentials below):<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker stop n8n &amp;&amp; docker rm n8n #stop and remove previous n8n container\ndocker run -d --name n8n \n  -p 5678:5678 \n  -e N8N_BASIC_AUTH_ACTIVE=true \n  -e N8N_BASIC_AUTH_USER=username \n  -e N8N_BASIC_AUTH_PASSWORD=password \n  -e N8N_HOST=yourdomain.com \n  -e N8N_PORT=5678 \n  -e WEBHOOK_URL=https:\/\/yourdomain.com\/ \n  -e GENERIC_TIMEZONE=UTC \n  -v ~\/.n8n:\/home\/node\/.n8n \n  n8nio\/n8n<\/pre><p>In addition to the n8n setup, you must consider other <a href=\"\/ca\/tutorials\/vps-security\">VPS security practices<\/a> since a vulnerable server can put your sensitive data at risk. For example, set up a proper firewall rule to ensure only permissible IP addresses can access your automation platform.<\/p><h3 class=\"wp-block-heading\">2. Keep your instance updated<\/h3><p>To maintain a secure n8n environment, be sure to regularly update the automation platform, its dependencies, and other underlying software. Using outdated packages can lead to broken workflows, security vulnerabilities, and a host of other problems.<\/p><p>The steps to update n8n depend on how you installed it. If you deploy n8n using npm, update it by running:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">npm update -g n8n<\/pre><p>If you use Docker Compose, update n8n by pulling the latest image. To do this, run these commands one by one:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Navigate to the directory containing your docker compose file\ncd &lt;\/path\/to\/your\/compose\/file\/directory&gt;\n\n# Pull latest version\ndocker compose pull\n\n# Stop and remove older version\ndocker compose down\n\n# Start the container\ndocker compose up -d<\/pre><p>Similarly, <a href=\"\/support\/11767754-how-to-update-n8n-at-hostinger\/\">update n8n installed with Hostinger&rsquo;s VPS template<\/a> using the Docker method. Our system automatically deploys n8n in a container for optimal reliability and isolation.<\/p><p>Meanwhile, update all other software packages on your system using the distro&rsquo;s built-in package manager. On Ubuntu, simply run:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update &amp;&amp; sudo apt upgrade -y<\/pre><h3 class=\"wp-block-heading\">3. Ensure persistence and backups<\/h3><p>Maintaining persistence and having a solid backup strategy are critical for a self-hosted n8n instance to ensure optimal data integrity. This is especially important if you deploy it using a Docker container.<\/p><p>When you run n8n on Docker, all of its data is stored inside the container&rsquo;s ephemeral file system. It is risky since the data of your automation platform will be wiped out if the container is deleted. <\/p><p>To prevent this, mount a persistent volume by running the following command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -v ~\/.n8n:\/home\/node\/.n8n ...<\/pre><p>This command maps the <strong>~\/.n8n <\/strong>directory on your host machine to the <strong>\/home\/node\/.n8n<\/strong> directory inside the Docker container. As a result, data n8n writes to its internal directory will be saved to your host machine&rsquo;s file system.<\/p><p>In addition to n8n, regularly back up the entire server to maintain data safety and simplify restoration in case of critical issues. You can use different tools for this task or do it manually by copying all files to another storage.<\/p><p>If you use Hostinger VPS solutions, an<strong> automatic weekly backup<\/strong> is active by default. We also offer a manual <strong>snapshot,<\/strong> which captures the current state of your VPS for easy recovery if you want to perform major server customizations.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-to-do-after-installing-n8n\">What to do after installing n8n?<\/h2><p>After installing n8n, explore the platform in more detail to discover how it can help streamline your projects or tasks. With hundreds of pre-built nodes, extensive application integrations, and custom application programming interface (API) compatibility, the possibilities of <a href=\"\/ca\/tutorials\/what-can-you-automate-with-n8n\">what you can automate with n8n<\/a> are incredibly vast.<\/p><p>For example, you can integrate Gmail with customer relationship management (CRM) software to automate a new customer onboarding process, or connect WhatsApp with the OpenAI API to create an AI-powered chatbot. For inspiration, check out our tutorial to learn about some of the most <a href=\"\/ca\/tutorials\/n8n-integrations\">popular n8n integrations<\/a>.<\/p><p>Instead of creating an automation system from scratch, you can also import <a href=\"\/ca\/tutorials\/best-n8n-templates\">pre-made n8n workflow templates<\/a> and expand them as needed. This is especially useful for beginners who are unsure about which nodes to use for a given task.<\/p><p>You can explore user-shared workflow templates for different tasks from the <a href=\"https:\/\/n8n.io\/workflows\/\" target=\"_blank\" rel=\"noopener\">official n8n repository<\/a>. Alternatively, Hostinger users can install the <strong>n8n (100+ workflows)<\/strong> template, which comes pre-configured with various workflow options.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Self-hosting n8n on an Ubuntu server offers enhanced data privacy, greater control, and efficiency than the managed, cloud hosting solution. Installing n8n also only takes a few steps if you already have a system with sufficient hardware resources that provides full root access to its terminal. There are three ways to self-host n8n on Ubuntu, [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-self-host-n8n\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":471,"featured_media":139207,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to self-host n8n on Ubuntu","rank_math_description":"Learn how to self-host n8n on an Ubuntu VPS using Hostinger\u2019s one-click template or manual setup to automate tasks easily and securely.","rank_math_focus_keyword":"how to self-host n8n","footnotes":""},"categories":[22701,22699],"tags":[],"class_list":["post-122902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-self-host-n8n","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-self-host-n8n","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/122902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/471"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=122902"}],"version-history":[{"count":29,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/122902\/revisions"}],"predecessor-version":[{"id":137265,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/122902\/revisions\/137265"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media\/139207"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=122902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=122902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=122902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}