Self-hosting Langflow on an Ubuntu Server

Self-hosting Langflow on an Ubuntu Server

Jonas Scholz - Co-Founder von sliplane.ioJonas Scholz
8 min

Want to build powerful AI workflows using Langflow but prefer to fully control your infrastructure? By self-hosting Langflow on a Linux Ubuntu server, you can cut down costs and manage your data yourself!

Follow along this easy-to-understand guide to learn how you can deploy your own Langflow instance using Docker and Caddy Web server for automatic HTTPS.

Before we start, make sure you have:

  • a running Ubuntu Linux server instance. A good option is Hetzner, but any Ubuntu server that you can login to with SSH and that has a public IP address works.
  • basic SSH experience.

Step 1: Update Your Server

Log into your Ubuntu server via SSH and update the system to ensure it has the latest security patches and updates.

sudo apt-get update
sudo apt-get upgrade -y

Once finished, your server is ready for installing the software.

Step 2: Install and Configure UFW Firewall

Only keep necessary ports open: SSH (22), HTTP (80), HTTPS (443).

Install UFW and configure the firewall as follows:

sudo apt install ufw -y
sudo ufw allow 22    # SSH
sudo ufw allow 80    # HTTP
sudo ufw allow 443   # HTTPS
sudo ufw enable

Check your firewall configuration:

sudo ufw status verbose

Note: Docker can sometimes ignore UFW rules. To tackle this, verify extra settings as explained here.

Step 3: Docker Installation

Docker will be the container system running Langflow. Install Docker by running these commands:

Setup dependencies and Docker's GPG key:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add Docker repository:

echo \
  "deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

Install Docker Engine and compose-plugin:

sudo apt-get install docker-ce docker-ce-cli \
containerd.io docker-buildx-plugin docker-compose-plugin -y

Check installation:

sudo docker run hello-world

If you see the "hello-world" message, Docker is ready.

Step 4: Installing Caddy for Automatic HTTPS

Caddy simplifies HTTPS configuration since it handles SSL certificates automatically from Let's Encrypt.

Install Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list

sudo apt update
sudo apt install caddy -y

Edit the Caddyfile configuration file:

sudo nano /etc/caddy/Caddyfile

Enter your domain and configure reverse proxy. Replace "yourdomain.com" with your actual domain name:

Caddyfile
yourdomain.com {
    reverse_proxy localhost:7860
}

If no domain yet, use this temporarily:

Caddyfile
:80 {
    reverse_proxy localhost:7860
}

Restart Caddy to load the config:

sudo systemctl restart caddy

Step 5: Running Langflow with Docker Compose

We're going to use Docker Compose for easier setup. First create a directory for Langflow and navigate to it:

mkdir ~/langflow
cd ~/langflow

SQLite Configuration (Simple Setup)

Create compose.yml with the following content for SQLite database:

compose.yml
services:
  langflow:
    image: docker.io/langflowai/langflow:latest
    restart: always
    ports:
      - "7860:7860"
    environment:
      - LANGFLOW_HOST=0.0.0.0
      - LANGFLOW_CONFIG_DIR=/app/langflow
      - LANGFLOW_SUPERUSER=admin
      - LANGFLOW_SUPERUSER_PASSWORD=change_me_to_secure_password
      - LANGFLOW_SECRET_KEY=your_secret_key_here
      - DO_NOT_TRACK=true
      - LANGFLOW_AUTO_LOGIN=false
    volumes:
      - langflow_data:/app/langflow

volumes:
  langflow_data:

PostgreSQL Configuration (Production Setup)

For production environments, PostgreSQL is recommended. Create compose.yml with the following content:

compose.yml
services:
  postgres:
    image: docker.io/library/postgres:16.4
    restart: always
    environment:
      - POSTGRES_USER=langflow
      - POSTGRES_PASSWORD=your_postgres_password
      - POSTGRES_DB=langflow
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  langflow:
    image: docker.io/langflowai/langflow:latest
    restart: always
    ports:
      - "7860:7860"
    environment:
      - LANGFLOW_HOST=0.0.0.0
      - LANGFLOW_CONFIG_DIR=/app/langflow
      - LANGFLOW_SUPERUSER=admin
      - LANGFLOW_SUPERUSER_PASSWORD=change_me_to_secure_password
      - LANGFLOW_SECRET_KEY=your_secret_key_here
      - DO_NOT_TRACK=true
      - LANGFLOW_AUTO_LOGIN=false
      - DATABASE_URL=postgresql://langflow:your_postgres_password@postgres:5432/langflow
    volumes:
      - langflow_data:/app/langflow
    depends_on:
      - postgres

volumes:
  langflow_data:
  postgres_data:

Important: Replace your_postgres_password, change_me_to_secure_password, and your_secret_key_here with secure values before deployment.

Now deploy Langflow by running Docker compose:

sudo docker compose up -d

Docker pulls the Langflow image and runs it in background mode using port 7860.

Step 6: Accessing Your Self-Hosted Langflow Instance

Visit your domain in any web browser. Your Langflow instance should now load successfully at https://yourdomain.com. Log in with the superuser credentials you configured to complete your initial setup.

Langflow dashboard

Security Recommendations

Public servers should always be secure. The following practises are recommended:

  • Regularly apply updates and security patches.
  • Set strong passwords and control user access.
  • Monitor server logs for suspicious activity.
  • Install tools like Fail2ban for extra security.
  • Use environment variables for secrets instead of hardcoding them.

Updating your Langflow Installation

When you want to update your Langflow instance, simply run:

sudo docker compose pull
sudo docker compose up -d

Docker will download updated versions automatically and replace your current containers.

Cost Comparison with Other Providers

Self-hosting Langflow typically results in lower cost compared to hosted services:

ProvidervCPURAMDiskMonthly CostNote
Sliplane22 GB50 GB€22.80Flat rate, free egress, SSL included
Fly.io22 GB40 GB~$17.83Disk and bandwidth billed separately
Render12 GB40 GB~$355 GB bandwidth included on Hobby; disk billed separately
Railway22 GB40 GBUp to ~$66Usage-based; Pro required for a 40 GB volume
Click here to see how these numbers were calculated.

Prices checked July 19, 2026. Assuming an always-on instance running 730 hrs/month, Germany/Amsterdam where regional pricing applies, excluding VAT and egress.

  • Sliplane: Base server with 2 vCPU, 2 GB RAM and 20 GB storage = €17.80/month; the 50 GB storage tier adds €5 -> €22.80/month. Unlimited services, free egress and SSL are included.
  • Fly.io: in Amsterdam, shared-cpu-2x with 2 GB RAM = $11.83/month + 40 GB volume × $0.15/GB = $6 -> ~$17.83/month. Egress is billed separately at $0.02/GB in Europe.
  • Render: closest match is Standard ($25, 1 vCPU / 2 GB) plus 40 GB disk × $0.25/GB = $10 -> ~$35/month. A Hobby workspace includes 5 GB bandwidth, then charges $0.15/GB. Stepping up to Pro compute (2 vCPU / 4 GB) costs $85/month plus disk.
  • Railway (Pro plan): at full resource usage: CPU 2 × $20/vCPU/month = $40; RAM 2 × $10/GB/month = $20; volume 40 × $0.15/GB/month = $6 -> up to ~$66/month. Actual CPU and RAM charges depend on usage. A 40 GB volume requires Pro; its $20/month subscription is a minimum commitment that counts toward usage, not an additional charge. Egress is $0.05/GB.

Bandwidth costs can add up fast on usage-based providers. Use our bandwidth cost comparison tool to see what your egress would cost on each platform.

Bandwidth Cost Growth Comparison

Move the slider or play the animation to compare monthly egress costs. Sliplane stays free as traffic grows.

0 GB
Sliplane
Free
Fly.io
$0.00
Railway
$0.00
Render
$0.00

Egress only, excluding compute and storage. Based on public US/European rates checked July 19, 2026. Render includes its first 5 GB per month. Sliplane egress is free, subject to the Fair Use Policy.

You maintain complete control and avoid additional usage-based charges by self-hosting. But of course there is no free lunch and you're now responsible for managing your own server!

Is anything missing with a self-hosted Langflow?

Self-hosted Langflow provides the full open-source experience with all features available. You can build complex AI workflows, integrate with various APIs and models, and customize everything according to your needs.

Now you have your own self-hosted Langflow instance running on Ubuntu! Time to start building your AI workflows.

If managing and securing your own server is a bit too much for you, check out how easy it is to deploy a managed instance of Langflow on sliplane (takes 45 seconds!)

Welcome to your cloud platform

Sliplane makes it simple to deploy and scale your apps in the cloud. Start with a container or your favorite framework and grow from there. Try it now and get started in minutes!