Blog / Tutorials / How to Self-Host Langflow with Docker on a VPS
(last updated: )

How to Self-Host Langflow with Docker on a VPS

Self-host Langflow with Docker Compose on a VPS: install, persistent database, Ollama connection, HTTPS and a first RAG flow, with security tips.

11 min read

Langflow is an open-source visual builder for LLM agents, RAG pipelines and tool-calling flows. To self-host it, run the official Langflow Docker image with Docker Compose, next to a PostgreSQL container with persistent volumes. Bind it to localhost, put a reverse proxy with HTTPS in front, and connect it to Ollama or any OpenAI-compatible API. The result is a self-hosted AI stack that you fully control.

What Is Langflow?

Langflow is an MIT-licensed platform for building AI applications on a drag-and-drop canvas. Each block on the canvas is a component, such as a model, a prompt, a document loader, a vector store or a tool. You connect components into a flow, test it in the built-in playground and serve it as an API endpoint. Langflow can also publish flows as tools over the Model Context Protocol (MCP).

Typical builds include chatbots that answer from your own documents, agents that call tools and APIs, and pipelines that classify or summarize data. Components are Python under the hood, so admins can open any block and change its code. Starter templates cover common patterns, so a first working flow takes minutes rather than hours.

Langflow sits in the same category as Flowise and Dify. Flowise offers a similar canvas built on Node.js. Dify bundles a full app platform with its own RAG pipeline and end-user apps. For classic workflow automation with a few AI steps, n8n on a VPS is often the better fit. This overview of self-hosted AI orchestration platforms compares the options, and a separate guide shows how to self-host Dify on a VPS.

Langflow Requirements: RAM, Storage and Database

The Langflow documentation lists a dual-core CPU and 2 GB RAM as the minimum. It recommends a multi-core CPU and at least 4 GB RAM. These figures cover Langflow alone. PostgreSQL, the reverse proxy and any local model need their own headroom. Storage grows with uploaded files and stored embeddings, so disk space matters for RAG-heavy use.

ComponentMinimumSmall production setup
Langflow application2 vCPU, 2 GB RAM4 vCPU, 4 GB RAM
PostgreSQL with pgvector512 MB RAM1 GB RAM
Disk (images, database, uploads)20 GB50 GB or more
Local Ollama on CPU (4B to 8B model)4 GB extra RAM8 GB extra RAM
Remote API or GPU model backendNo extra RAMNo extra RAM

For Langflow and PostgreSQL with a remote model, a Core VPS such as Cloud VPS 4 (4 vCPU cores, 8 GB RAM) is enough. To run a small model on the CPU as well, choose Cloud VPS 6 (12 GB) or Cloud VPS 8 (24 GB). Larger models belong on a GPU server.

Undersized servers usually fail quietly. The kernel kills the biggest process, often Ollama or Langflow, and the container restarts mid-request. Check live memory use and the kernel log if flows stop without a clear error:

docker stats --no-stream
sudo dmesg -T | grep -i "killed process"

If the log shows killed processes, switch to a smaller model or move to a plan with more RAM.

How to Install Langflow with Docker Compose

This Langflow install assumes Ubuntu 24.04 with Docker Engine and the Compose plugin. If Docker isn’t set up yet, follow the guide to install Docker on Ubuntu first. Create a project folder and generate two random secrets, one for the database password and one for the encryption key.

mkdir -p ~/langflow && cd ~/langflow
openssl rand -hex 32
openssl rand -hex 32

Create a file named .env and paste in the generated values:

POSTGRES_PASSWORD=paste-first-secret-here

LANGFLOW_SECRET_KEY=paste-second-secret-here

LANGFLOW_AUTO_LOGIN=false

LANGFLOW_SUPERUSER=admin

LANGFLOW_SUPERUSER_PASSWORD=choose-a-strong-password

LANGFLOW_NEW_USER_IS_ACTIVE=false

Langflow 1.13 disables auto-login by default, so the superuser password must exist before the first start. The secret key encrypts stored credentials, so keep it stable. New self-registered accounts stay inactive until an admin approves them.

Now create docker-compose.yml:

services:

  langflow:

    image: langflowai/langflow:1.13.3

    restart: unless-stopped

    depends_on:

      postgres:

        condition: service_healthy

    ports:

      - "127.0.0.1:7860:7860"

    env_file: .env

    environment:

      - LANGFLOW_DATABASE_URL=postgresql://langflow:${POSTGRES_PASSWORD}@postgres:5432/langflow

      - LANGFLOW_CONFIG_DIR=/app/langflow

    volumes:

      - langflow-data:/app/langflow

  postgres:

    image: pgvector/pgvector:pg16

    restart: unless-stopped

    environment:

      - POSTGRES_USER=langflow

      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}

      - POSTGRES_DB=langflow

    healthcheck:

      test: ["CMD-SHELL", "pg_isready -U langflow -d langflow"]

      interval: 10s

      timeout: 5s

      retries: 5

    volumes:

      - langflow-postgres:/var/lib/postgresql/data

volumes:

  langflow-data:

  langflow-postgres:

The image is pinned to 1.13.3, the newest patch release at the time of writing. Check the Langflow releases page for anything newer. The pgvector image is standard PostgreSQL 16 with the vector extension preinstalled, so the same database can store embeddings later. Port 7860 binds to 127.0.0.1 because Docker publishes ports past UFW rules. The named volumes keep the database, secret key and uploads when containers are recreated.

Start the stack and watch the logs:

docker compose up -d
docker compose logs -f langflow

To test before HTTPS is in place, open an SSH tunnel from your own machine and browse to http://localhost:7860:

ssh -L 7860:127.0.0.1:7860 user@your-server-ip

If sign-in fails, check that the .env file sits next to docker-compose.yml. Upgrades from older versions are a common cause, because they relied on auto-login. In that case, follow the recover access steps in the Langflow docs.

Connect Langflow to Ollama or an OpenAI-Compatible API

Langflow reaches models through components. The core Language Model component supports common providers, and the Ollama bundle adds an Ollama component with extra settings. Inside a container, localhost points to the container itself. The default Ollama address of http://127.0.0.1:11434 therefore fails with a connection error.

The simplest Langflow Ollama setup runs Ollama in the same Compose project. Paste this fragment under the existing services key and keep its two-space indent. Then add ollama: as a new entry under volumes.

ollama:

    image: ollama/ollama:latest

    restart: unless-stopped

    volumes:

      - ollama:/root/.ollama

Apply the change, then pull a chat model and an embedding model:

docker compose up -d
docker compose exec ollama ollama pull qwen3:4b
docker compose exec ollama ollama pull nomic-embed-text

In the Ollama and Ollama Embeddings components, set the base URL to http://ollama:11434. Docker resolves the service name, and the port never leaves the server. Choose the embedding model carefully, because changing it later means re-embedding every document. CPU inference works for testing but slows down quickly with larger models. The Open WebUI and Ollama guide shows how to give the same container GPU access.

For production traffic, run vLLM on a GPU server and use its OpenAI-compatible endpoint. Pick an OpenAI-compatible model component and set the base URL to http://GPU_SERVER_IP:8000/v1. Enter the model name that vLLM serves. A placeholder API key works unless you started vLLM with –api-key. Keep port 8000 on a private network or restrict it to your Langflow server’s IP. The LLM inference guide covers the vLLM side of this self-hosted AI setup.

Langflow Tutorial: Build Your First RAG Flow

This Langflow tutorial builds a chatbot that answers questions from your own documents.

  1. Create a new flow from the Vector Store RAG template. It contains a Load Data subflow for ingestion and a Retriever subflow for chat.
  2. Replace both Astra DB components with a vector store you can reach, such as PostgreSQL with pgvector or OpenSearch. Install the matching bundle first if it is missing. Chroma is retired in Langflow 1.13, so older tutorials that use it no longer apply.
  3. In the Read File component, upload a PDF, Markdown or text file. In Split Text, keep the chunk size within your embedding model’s token limit.
  4. Swap both OpenAI Embeddings components for Ollama Embeddings with nomic-embed-text. Use the same embedding model in both subflows, or search results become inaccurate.
  5. In the Language Model component, select your Ollama model or vLLM endpoint. The Chat Output component already receives its answer.
  6. Run the Load Data subflow from the vector store component. Then open the Playground and ask a question that your document answers.
  7. Create an API key under Settings, and open Share and then API access to copy a ready-made snippet.

The Compose database already ships the pgvector extension, but Langflow doesn’t enable it for you. Enable it once with this command:

docker compose exec postgres psql -U langflow -d langflow -c “CREATE EXTENSION IF NOT EXISTS vector;”

Langflow also needs a PGVECTOR_CONNECTION_STRING variable and its pgvector dependency, as the Langflow vector data docs describe. Without the extension, vector operations fail with an error rather than storing data.

A basic API call to the finished flow looks like this:

curl -X POST "https://langflow.example.com/api/v1/run/FLOW_ID" \

  -H "Content-Type: application/json" \

  -H "x-api-key: $LANGFLOW_API_KEY" \

  -d '{"input_value": "What does the document say about pricing?", "input_type": "chat", "output_type": "chat"}'

Secure Langflow: HTTPS, Authentication and Updates

  • Never expose Langflow without authentication. Keep auto-login disabled and never set LANGFLOW_SKIP_AUTH_AUTO_LOGIN on a public server.
  • Pin a patched version. An IBM bulletin from October 2026 lists two CVSS 9.8 flaws in versions 1.0.0 to 1.12.8, fixed in 1.13.0. A November bulletin covers releases up to 1.13.0, so run 1.13.1 or later.
  • Track advisories before every upgrade. Several Langflow flaws sit in CISA’s Known Exploited Vulnerabilities catalog, and attackers actively scan for exposed instances.
  • Terminate TLS at a reverse proxy. Caddy obtains a Let’s Encrypt certificate automatically with the configuration below.
  • Keep custom code limited to admins. Since 1.13.2, Langflow restricts custom-code authoring to admins by default, so leave that setting alone unless every editor is trusted.
  • Open only SSH, HTTP and HTTPS in the firewall. Restrict editor access further with a VPN or an IP allowlist where possible.
  • Back up the PostgreSQL database and the langflow-data volume. The volume holds the secret key, and without it saved credentials can’t be decrypted.

Caddy configuration in /etc/caddy/Caddyfile:

langflow.example.com {

    reverse_proxy 127.0.0.1:7860

}

Firewall rules:

sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable

Backup commands, run from ~/langflow:

docker compose exec -T postgres pg_dump -U langflow langflow > langflow-$(date +%F).sql
docker run --rm -v langflow_langflow-data:/data -v "$PWD":/backup alpine tar czf /backup/langflow-data-$(date +%F).tar.gz -C /data .

To update, take a backup, change the image tag in docker-compose.yml, and run:

docker compose pull && docker compose up -d

Langflow vs Flowise: Which Should You Self-Host?

 LangflowFlowise
UI modelCanvas with Python components you can editCanvas with Chatflow and Agentflow builders
Agents and RAGAgent component, MCP client and server, knowledge basesAgentflow for multi-agent work, document stores
RuntimePythonNode.js
EcosystemMIT license, backed by IBMApache 2.0 core, part of Workday

The Langflow vs Flowise choice mostly comes down to language. Pick Langflow if your team writes Python and wants MCP support built in. Pick Flowise if your stack is JavaScript. Flowise Docker deployment is similar, using the flowiseai/flowise image on port 3000.

Why Run Langflow on Contabo

Langflow and PostgreSQL need RAM more than raw CPU speed, and that is where Core VPS plans deliver. Cloud VPS 4 offers 4 vCPU cores and 8 GB RAM, which covers the application, the database and a reverse proxy. Cloud VPS 6 with 12 GB RAM adds room for a small CPU model. Every plan includes snapshots, so you can capture the server before an upgrade and roll back quickly if a migration fails. Check the Core VPS page for current pricing, since promotions change often.

For larger models, keep Langflow on a Core VPS and run inference on a separate GPU VPS. The orchestration layer stays cheap, while the GPU server handles vLLM or Ollama. EU data centers keep prompts and documents inside GDPR-friendly infrastructure, which matters for any self-hosted AI project with customer data.

FAQ: Self-Hosting Langflow

How do I install Langflow with Docker?

Create a .env file with a superuser password and a secret key, then define Langflow and PostgreSQL in a Compose file. Pin the langflowai/langflow image to a patched version and run docker compose up -d. Bind port 7860 to localhost and add a reverse proxy for HTTPS.

Can Langflow use Ollama for local models?

Yes. Use the Ollama component for chat and Ollama Embeddings for vectors. When both run in the same Compose project, set the base URL to http://ollama:11434. Don’t use 127.0.0.1, because inside the Langflow container it points to Langflow itself.

What is the difference between Langflow and Flowise?

Both are visual builders for LLM apps and agents. Langflow runs on Python, lets admins edit component code, and supports MCP natively. Flowise runs on Node.js and offers separate Chatflow and Agentflow builders. The choice usually depends on your team’s preferred language.

How much RAM does Langflow need?

The official minimum is 2 GB RAM, with at least 4 GB recommended. Add about 1 GB for PostgreSQL. A server with 8 GB RAM runs Langflow comfortably with a remote model. Running a local model on the same server needs more memory, about 4 GB extra for a 4B model on CPU.

Is it safe to expose Langflow to the internet?

Only with authentication, HTTPS and a patched release. Several Langflow vulnerabilities have been exploited in the wild, and versions up to 1.12.8 contain critical unauthenticated flaws. Run 1.13.1 or newer, keep auto-login off and restrict editor access with a firewall or VPN.

Share 𝕏 in