Build AI Agents Locally and Access Them Anywhere with Langflow

Published: (March 17, 2026 at 08:12 AM EDT)
6 min read
Source: Dev.to

Source: Dev.to

Building AI Agents with Langflow – From Local Install to Public Access

There was a time when building AI agents meant stitching together multiple libraries, writing glue code, and debugging small mismatches between APIs. That approach still exists, but tools like Langflow have made the process far more approachable. Instead of writing everything from scratch, you now work on a visual canvas where components connect like building blocks.

What makes this even more interesting is that you can run the entire system on your own machine. Your workflows, data, and experiments stay local. The trade‑off is that, by default, the service is only reachable on your local network. If you want to test your agent on your phone, share it with someone else, or integrate it with an external service, you need a way to expose it.

This guide walks through that journey in a practical, grounded way. You will:

  1. Install Langflow and run it locally.
  2. Make it accessible from anywhere using a simple tunneling approach.

Understanding Langflow in Practice

Langflow is a visual environment for building AI pipelines. Instead of writing long scripts, you connect components—language models, vector databases, APIs, logic blocks—on a canvas.

  • Each workflow becomes a working API endpoint.
  • The flow is interactive in the UI and usable in real applications.
  • Flexibility: Switch between providers, run local inference, or hook up external tools as needed.

Why Running It Locally Makes Sense

BenefitWhy it matters
PrivacySensitive documents or internal datasets never leave your machine.
CostPair with local models to avoid usage‑based billing.
CustomizationChoose your environment, services, and storage configuration.

Getting Started with Installation

You can install Langflow in several ways, depending on your comfort with Python environments.

pip install uv
uv pip install langflow
uv run langflow run

Option 2 – Using pip (if you already manage Python manually)

pip install langflow
langflow run

Option 3 – Using Docker (no local dependency management)

docker run -p 7860:7860 langflowai/langflow:latest

After the command starts, open your browser at:

http://localhost:7860

You should see the Langflow interface ready to use.


Running Langflow on a Different Port

If port 7860 is already occupied, change it:

langflow run --port 8080

Or set an environment variable:

export LANGFLOW_PORT=8080
langflow run

A More Stable Setup with Docker Compose

For longer‑term usage (persistence, database, easy restarts), Docker Compose is a better choice.

docker-compose.yml

services:
  langflow:
    image: langflowai/langflow:latest
    pull_policy: always
    ports:
      - "7860:7860"
    depends_on:
      - postgres
    env_file:
      - .env
    environment:
      - LANGFLOW_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
      - LANGFLOW_CONFIG_DIR=/app/langflow
    volumes:
      - langflow-data:/app/langflow

  postgres:
    image: postgres:16
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - langflow-postgres:/var/lib/postgresql/data

volumes:
  langflow-postgres:
  langflow-data:

.env

POSTGRES_USER=langflow
POSTGRES_PASSWORD=changeme
POSTGRES_DB=langflow
LANGFLOW_SUPERUSER=admin
LANGFLOW_SUPERUSER_PASSWORD=changeme
LANGFLOW_AUTO_LOGIN=False

Start everything:

docker compose up -d

This setup ensures your flows and configurations persist across restarts.


Making Your Local Setup Accessible

Running Langflow locally limits access to your machine. To expose it publicly, create a tunnel. One simple, free option is Pinggy.

Create a Public URL

ssh -p 443 -R0:localhost:7860 free.pinggy.io

After the command runs, Pinggy returns a public URL that forwards traffic to your local Langflow instance. Open that link from any device to access Langflow remotely.

Adding Basic Protection

If you share the URL, protect it with basic authentication:

ssh -p 443 -R0:localhost:7860 -t free.pinggy.io b:username:password

Only users who know the username and password can reach your setup.


Building Your First Flow

Now that Langflow is up and reachable, you can start creating workflows. A simple starter is a question‑answering flow:

  1. Drag a LLM component (e.g., OpenAI, Llama‑cpp).
  2. Add a Prompt node that formats the user’s question.
  3. Connect the Prompt to the LLM and expose the output as an API endpoint.
  4. Test the endpoint via the UI or with curl:
curl -X POST http:///api/v1/flow//run \
     -H "Content-Type: application/json" \
     -d '{"input": "What is Langflow?"}'

You now have a fully functional AI agent that you can call from any client, on any device.


Recap

StepWhat you did
InstallChose uv / pip / Docker (or Docker Compose) and started Langflow locally.
ExposeUsed Pinggy to create a public URL, optionally adding basic auth.
BuildDesigned a visual workflow that becomes a callable API.

With Langflow running locally and reachable from anywhere, you have a powerful, private, and cost‑effective platform for prototyping and deploying AI agents. Happy building!

Agent that fetches information from the web

Basic components include

  • Chat Input – user queries
  • Search tool – fetches information
  • Parser – converts structured data into text
  • Prompt Template – combines inputs
  • Language model – generates responses
  • Chat Output – displays results

You connect these components visually; each connection shows how data flows from one step to the next.


Exploring a RAG Workflow

One of the most practical use cases is Retrieval‑Augmented Generation (RAG).
In simple terms, you allow your agent to answer questions based on your own documents.

Typical flow

  1. Upload a document
  2. Split it into smaller chunks
  3. Convert those chunks into embeddings
  4. Store them in a vector database
  5. Retrieve relevant pieces during a query
  6. Combine them with the question
  7. Generate a final answer

This approach makes your agent far more useful for domain‑specific tasks.


Running Everything Locally with Ollama

If you want complete control, you can avoid external APIs entirely.

Start a local model

ollama pull llama3.2
ollama serve

Connect Langflow

http://localhost:11434

Now the entire pipeline runs on your own machine, from document processing to response generation.


Using Your Flow as an API

Every workflow you build can be called programmatically.

Example request

curl -X POST \
  "http://localhost:7860/api/v1/run/" \
  -H "Content-Type: application/json" \
  -d '{"input_value": "What does the document say about pricing?"}'

Replace localhost with your public tunnel URL to call your agent from anywhere.


Flexibility Across Tools and Models

Langflow supports a wide range of integrations. You can experiment with different models, connect various databases, and integrate external services without changing your entire setup.

This flexibility makes it useful not only for experimentation but also for building real applications.


Conclusion

Self‑hosting Langflow changes how you approach building AI systems. Instead of relying entirely on external platforms, you gain ownership over your workflows and data.

Adding remote access completes the picture: it lets your local setup behave like a deployable service without the overhead of managing servers.

The combination of a visual builder, local control, and simple remote access creates a workflow that feels both powerful and practical. It lowers the barrier to experimentation while still providing the tools needed for more serious projects.


Reference

How to Self‑Host Langflow and Access It Remotely

0 views
Back to Blog

Related posts

Read more »