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

> Source: <https://dev.to/vultr/deploying-langflow-an-open-source-visual-framework-for-building-ai-applications-19ol>
> Published: 2026-09-23 19:16:50+00:00

[Langflow](https://github.com/langflow-ai/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.

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:**

``` bash
$ mkdir ~/langflow && cd ~/langflow
```

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

``` python
$ python3 -c "from secrets import token_urlsafe; print(f'LANGFLOW_SECRET_KEY={token_urlsafe(32)}')" >> .env
```

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:**

``` bash
$ grep -c "LANGFLOW_SECRET_KEY" .env
```

Output:

```
1
```

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

``` bash
$ nano .env
```

**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
```

`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:**

``` bash
$ chmod 600 .env
```

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:**

``` bash
$ nano docker-compose.yml
```

**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:
```

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:**

``` bash
$ docker compose up -d
```

**4. Verify that all containers are running:**

``` bash
$ docker compose ps
```

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:**

``` bash
$ docker compose logs -f langflow
```

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.

```
Open Langflow → http://localhost:7860
```

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.

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

`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.`LANGFLOW_SUPERUSER` and `LANGFLOW_SUPERUSER_PASSWORD`. The Langflow `OPENAI_API_KEY` variable at startup. Enable the models you plan to use under 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.

`langflow_demo`, select an OpenAI embedding model, and keep `{question}` variable. `{context}`. For the full guide with additional tips, visit the original article on **[Vultr Docs](https://docs.vultr.com/how-to-deploy-langflow-open-source-visual-framework-for-building-ai-applications)**.
