DEV Community

Cover image for Deploying Langflow: An Open-Source Visual Framework for Building AI Applications
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Deploying Langflow: An Open-Source Visual Framework for Building AI Applications

Langflow is an open-source, low-code visual framework for building artificial intelligence (AI) agents, workflows, and retrieval-augmented generation (RAG) applications. Developers use its visual builder to assemble large language model (LLM) pipelines from prebuilt components and test them in an interactive Playground, and finished flows run as API endpoints or Model Context Protocol (MCP) servers without extra boilerplate code. This guide walks through self-hosting a production-ready Langflow instance on a Linux server with Docker Compose, covering PostgreSQL persistence, Traefik reverse proxying with automatic HTTPS certificates, authentication for the visual editor, and validation of the deployment through a RAG chatbot that answers questions from an uploaded document. By the end, you'll have a secured Langflow deployment running behind HTTPS with a working RAG chatbot proving that ingestion, retrieval, and generation all work end to end.

Before you begin, you need a Linux-based server with at least 2 CPU cores and 4 GB of RAM as a non-root user with sudo privileges, Docker and Docker Compose installed, a domain A record pointing to the server's public IP address (for example, langflow.example.com), and an API key from a supported LLM provider — this deployment uses OpenAI models for embeddings and chat responses.


1. Set Up the Project Directory and Environment

Langflow reads its runtime configuration from environment variables, so a dedicated project directory with a .env file keeps credentials out of the Compose manifest.

1. Create the project directory and switch into it:

$ mkdir ~/langflow && cd ~/langflow
Enter fullscreen mode Exit fullscreen mode

2. Generate a Langflow secret key and write it to the environment file:

$ python3 -c "from secrets import token_urlsafe; print(f'LANGFLOW_SECRET_KEY={token_urlsafe(32)}')" >> .env
Enter fullscreen mode Exit fullscreen mode

Langflow encrypts stored credentials with this Fernet key. Without an explicit key, Langflow generates a random one at startup and encrypted values become unreadable after a restart.

3. Verify that the file contains the key without displaying its value:

$ grep -c "LANGFLOW_SECRET_KEY" .env
Enter fullscreen mode Exit fullscreen mode

Output:

1
Enter fullscreen mode Exit fullscreen mode

4. Open the .env file with a text editor such as nano:

$ nano .env
Enter fullscreen mode Exit fullscreen mode

5. Add the following variables below the existing LANGFLOW_SECRET_KEY line, replacing every placeholder with your own values:

# Domain and certificate settings
LANGFLOW_HOSTNAME=langflow.example.com
LETSENCRYPT_EMAIL=admin@example.com

# PostgreSQL credentials
POSTGRES_USER=langflow
POSTGRES_PASSWORD=DATABASE_PASSWORD
POSTGRES_DB=langflow

# Langflow storage paths
LANGFLOW_CONFIG_DIR=/app/langflow
LANGFLOW_KNOWLEDGE_BASES_DIR=/app/langflow/knowledge_bases

# Authentication settings
LANGFLOW_AUTO_LOGIN=False
LANGFLOW_SUPERUSER=administrator
LANGFLOW_SUPERUSER_PASSWORD=ADMIN_PASSWORD
LANGFLOW_NEW_USER_IS_ACTIVE=False
LANGFLOW_ENABLE_SUPERUSER_CLI=False

# LLM provider credentials
OPENAI_API_KEY=OPENAI_API_KEY
Enter fullscreen mode Exit fullscreen mode

LANGFLOW_HOSTNAME and LETSENCRYPT_EMAIL supply the domain for the Traefik routing rule and the contact address for certificate expiry notices. The POSTGRES_* variables initialize the database container on first boot and are reused in the Langflow connection string — use only letters and numbers in the password, because symbols require %-encoding and $ conflicts with Compose interpolation. LANGFLOW_CONFIG_DIR and LANGFLOW_KNOWLEDGE_BASES_DIR place application data and knowledge base vectors on the same volume-mapped path; without the second variable, Langflow writes knowledge bases outside that volume and a container replacement deletes your vector data. LANGFLOW_AUTO_LOGIN=False disables anonymous access, LANGFLOW_SUPERUSER/LANGFLOW_SUPERUSER_PASSWORD define the administrator account Langflow creates at startup, LANGFLOW_NEW_USER_IS_ACTIVE=False keeps new accounts inactive until approved, and LANGFLOW_ENABLE_SUPERUSER_CLI=False blocks superuser creation from the command line. OPENAI_API_KEY supplies the LLM provider credential, which Langflow stores as an encrypted global variable.

6. Restrict the environment file so only its owner can read or modify it:

$ chmod 600 .env
Enter fullscreen mode Exit fullscreen mode

2. Deploy with Docker Compose

The stack runs three services. Traefik terminates HTTPS, Langflow serves the application on internal port 7860, and PostgreSQL stores flows, users, and settings. Langflow joins the proxy network with Traefik and the internal network with PostgreSQL, so the database stays unreachable from outside.

1. Create the docker-compose.yml file in the project directory:

$ nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

2. Add the following service definitions to the file:

services:
  traefik:
    image: traefik:v3.7
    restart: unless-stopped
    command:
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --providers.docker.network=proxy
      - --entryPoints.web.address=:80
      - --entryPoints.websecure.address=:443
      - --entryPoints.websecure.http.tls=true
      - --entryPoints.web.http.redirections.entryPoint.to=websecure
      - --entryPoints.web.http.redirections.entryPoint.scheme=https
      - --certificatesresolvers.le.acme.email=${LETSENCRYPT_EMAIL}
      - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.le.acme.httpchallenge.entrypoint=web
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt:/letsencrypt
    networks:
      - proxy

  langflow:
    image: langflowai/langflow:1.11.3
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - LANGFLOW_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
      - LANGFLOW_CONFIG_DIR=${LANGFLOW_CONFIG_DIR}
      - LANGFLOW_KNOWLEDGE_BASES_DIR=${LANGFLOW_KNOWLEDGE_BASES_DIR}
      - LANGFLOW_AUTO_LOGIN=${LANGFLOW_AUTO_LOGIN}
      - LANGFLOW_SUPERUSER=${LANGFLOW_SUPERUSER}
      - LANGFLOW_SUPERUSER_PASSWORD=${LANGFLOW_SUPERUSER_PASSWORD}
      - LANGFLOW_SECRET_KEY=${LANGFLOW_SECRET_KEY}
      - LANGFLOW_NEW_USER_IS_ACTIVE=${LANGFLOW_NEW_USER_IS_ACTIVE}
      - LANGFLOW_ENABLE_SUPERUSER_CLI=${LANGFLOW_ENABLE_SUPERUSER_CLI}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    volumes:
      - langflow-data:/app/langflow
    networks:
      - proxy
      - internal
    labels:
      - traefik.enable=true
      - traefik.http.routers.langflow.rule=Host(`${LANGFLOW_HOSTNAME}`)
      - traefik.http.routers.langflow.entrypoints=websecure
      - traefik.http.routers.langflow.tls.certresolver=le
      - traefik.http.services.langflow.loadbalancer.server.port=7860

  postgres:
    image: postgres:16-trixie
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 10
    volumes:
      - langflow-postgres:/var/lib/postgresql/data
    networks:
      - internal
networks:
  proxy:
    name: proxy
  internal:

volumes:
  langflow-data:
  langflow-postgres:
Enter fullscreen mode Exit fullscreen mode

The traefik service publishes ports 80 and 443, discovers only explicitly labeled containers through the read-only Docker socket, and registers a certificate resolver named le that completes the ACME challenge on port 80 and redirects plain HTTP to HTTPS. The langflow service pins the langflowai/langflow:1.11.3 image; the Traefik labels route your domain to port 7860 inside the container, and the langflow-data volume persists LANGFLOW_CONFIG_DIR across restarts. The postgres service pins postgres:16-trixie, joins only the internal network, and its pg_isready health check gates the Langflow start.

3. Start the stack in detached mode:

$ docker compose up -d
Enter fullscreen mode Exit fullscreen mode

4. Verify that all containers are running:

$ docker compose ps
Enter fullscreen mode Exit fullscreen mode

The output displays three running containers, with Traefik listening on ports 80 and 443 and PostgreSQL reporting a healthy status.

5. Check the Langflow logs to verify that the application started:

$ docker compose logs -f langflow
Enter fullscreen mode Exit fullscreen mode

The first start takes a few minutes because Langflow runs its database migrations against PostgreSQL. The log stream ends with a startup banner when the application is ready.

Output:

Open Langflow → http://localhost:7860
Enter fullscreen mode Exit fullscreen mode

Press Ctrl+C to stop following the logs. The localhost address applies inside the container only, and Traefik forwards your domain traffic to the same listener.

3. Access and Configure Langflow

The stack now runs behind HTTPS, so the remaining configuration happens in the browser.

  1. Open a web browser and visit your Langflow domain, such as https://langflow.example.com. Traefik requests a Let's Encrypt certificate after the stack starts — if the browser shows a certificate warning, wait a minute and reload. Because automatic login is off, Langflow redirects you to the /login page.
  2. Log in with the values you set for LANGFLOW_SUPERUSER and LANGFLOW_SUPERUSER_PASSWORD. The Langflow Projects page opens.
  3. Verify the model provider: click your profile icon in the header, select Settings, then Model Providers. OpenAI appears as configured because Langflow detects the OPENAI_API_KEY variable at startup. Enable the models you plan to use under Language Models and Embedding Models.
  4. Verify the stored credential: in Settings, click Global Variables. A variable named OPENAI_API_KEY appears with the Credential type, which masks its value in the visual editor.

4. Build a RAG Chatbot to Validate the Deployment

A RAG chatbot answers questions from your own documents instead of relying only on the model's training data. Langflow ships a Vector Store RAG template that pairs a retrieval flow with a knowledge base, which chunks a document, embeds it, and stores the vectors locally. A grounded answer in the Playground proves that ingestion, retrieval, and generation all work on the deployed stack.

Create a Knowledge Base from a Sample Document

  1. On the Projects page, click Knowledge below the list of projects, then click Add Knowledge.
  2. In the Create Knowledge Base pane, enter a name such as langflow_demo, select an OpenAI embedding model, and keep Chroma Local as the DB Provider — it stores vectors on the server, so the knowledge base requires no external database account.
  3. Click Add Files and select a document from your local machine, such as a product manual or a policy document.
  4. Keep the default values for Chunk Size, Chunk Overlap, and Separator, then click Next Step.
  5. Review the sample chunk in the Review & Build pane, then click Create. Langflow splits the document into chunks, converts each chunk into a vector, and indexes the results.
  6. Wait until the knowledge base Status changes to Ready, which means the ingestion pipeline completed without errors.

Create the Flow from the Vector Store RAG Template

  1. On the Projects page, click New Flow, then select the Vector Store RAG template.
  2. Review how the components connect: Chat Input sends each question to Knowledge as the Search Query and to Prompt as the {question} variable. Knowledge returns matching chunks, Parser extracts their text, and Prompt inserts that text as {context}. Agent generates the answer, and Chat Output returns it.
  3. In the Knowledge component, keep Retrieve as the Mode, and select your langflow_demo knowledge base. Retrieval reuses the embedding model from ingestion, so query vectors and stored vectors stay comparable.
  4. In the Agent component, select an OpenAI chat model in the Language Model field. The template preloads Agent Instructions with a retrieval-focused system prompt.
  5. Review the Prompt component. Adjust the wording if you want a different tone, but keep the {context} and {question} placeholders intact.

Test the Chatbot in the Playground

  1. Click Playground. A chat panel opens.
  2. Type a question that only your uploaded document can answer, then press Enter.
  3. Read the response — the flow runs a semantic search against the knowledge base, pulls the most similar chunks, and instructs the language model to answer from that context.
  4. Ask a follow-up question about a different part of the document to verify that retrieval covers the full file rather than a single chunk.

Next Steps

  • Add more LLM providers (Anthropic, Gemini, and others) as global variables and swap models per flow.
  • Explore other Langflow templates for agents and multi-step pipelines.
  • Publish a flow as an API endpoint or MCP server to power a downstream application.
  • Set up scheduled PostgreSQL backups to protect your flow and knowledge base data.

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)