
Run Ollama+n8n on a Linux VPS: build your own private AI automation server
Imagine an automation stack that never charges a monthly subscription fee, operates entirely within your own secure server, and leverages the full power of private, local AI. While most creators are burning their budgets on escalating Zapier costs and compromising data privacy by sending sensitive info to third-party clouds, you could be operating an independent, infinitely scalable automation ecosystem. By combining the visual power of n8n with the intelligence of Ollama, you reclaim total control over your workflow .in this guide, I’ll show you exactly how to build your own private AI automation server and run ollama + n8n on a VPS.
What are Ollama and n8n on Linux VPS?
Imagine having a tireless digital assistant that works 24/7, costs nothing in monthly subscriptions, and keeps all your information strictly private. By combining n8n and Ollama, you build a custom setup where n8n acts as the “traffic controller” moving data between your apps, while Ollama serves as your private “AI brain.” Because both run entirely on your own server, your workflows stay fast, secure, and completely independent of external cloud providers.
- n8n: This is your visual automation hub. It’s a tool where you draw connections between your apps to move data automatically. You run n8n on a VPS to build complex, multi-step workflows without ever worrying about monthly subscription fees or task limits.
- Ollama: This is your private AI engine. Run ollama on a Linux VPS allows you to run smart language models (like Llama or Mistral) directly on your own hardware. You use it to handle all your AI tasks—like writing, summarizing, or analysing data instantly and privately, without sending a single byte of data to third-party companies.
Key Benefits of Automating Workflows with n8n and Ollama
Self-hosting your AI stack means moving away from the “black box” of third-party APIs and taking complete ownership of your digital infrastructure. Instead of relying on external services that dictate your costs, privacy policies, and feature roadmaps, you run your own models and automation tools directly on your server. While it requires more initial setup, this shift provides a unique blend of data sovereignty, cost predictability, and architectural freedom that cloud-based platforms simply cannot match.
- Total Privacy & Security: Your sensitive data, documents, and internal history never leave your server or get used to train external models.
- Cost Predictability: You eliminate expensive usage-based pricing and per-user subscriptions, paying only for your flat hosting costs.
- Unrivaled Control: You alone decide which models to use, when to update them, and how your system architecture evolves, free from external service limits.
- Independence: You are immune to the roadmap changes, service outages, or price hikes imposed by third-party SaaS providers.
Choosing the Right VPS Configuration for Your AI Automation Stack
Selecting the ideal server specifications depends entirely on your expected workload rather than a one-size-fits-all rule. While light automation tasks and smaller language models require minimal resources, scaling up to heavier models or running multiple applications simultaneously demands careful RAM planning. The following breakdown helps you align your server capacity with your operational needs, ensuring smooth performance and cost efficiency. Run ollama + n8n on a Linux VPS needs below configuration tips.
| Plan | vCPU | RAM | Storage | Typical Use Case |
| Deploy Apps — Pro | 2 vCPU | 2 GB | 25 GB SSD | Ideal for n8n workflows, a small local model, or a lightweight assistant. |
| Deploy Apps — Power | 4 vCPU | 4 GB | 50 GB SSD | Great for running Open WebUI and Ollama with a more comfortable setup. |
| VPS 1 (Entry Tier) | 4 vCPU | 6 GB | 100 GB NVMe | Suited for heavier language models requiring extra RAM headroom. |
| VPS 6 (Top Tier) | 24 vCPU | 120 GB | 600 GB NVMe | Built for running multiple models concurrently and handling intensive workloads. |
Deployment Guide: Setting Up Your n8n + Ollama Stack with Docker
Deploying this stack is remarkably simple with Docker Compose. Instead of installing components manually, we use a single configuration file to run ollama + n8n on a VP. This keeps your system clean, organized, and easy to update.
Follow these four steps to get your automation server running:
Step 1: Prepare your workspace
First, create a dedicated directory on your server to keep your automation files organized. Open your terminal and run the following commands:
mkdir automation-stack cd automation-stack
Step 2: Create the configuration file
Now, create a new file named docker-compose.yml in that directory. You can use an editor like nano or vi. Paste the following content into the file:
services: n8n: image: n8nio/n8n:latest restart: always ports: - "5678:5678" environment: - N8N_HOST=localhost - WEBHOOK_URL=http://localhost:5678/ volumes: - n8n_data:/home/node/.n8n ollama: image: ollama/ollama:latest restart: always ports: - "11434:11434" volumes: - ollama_data:/root/.ollama volumes: n8n_data: ollama_data:
Step 3: Launch the services
Once you have saved the file, start both services in the background using Docker Compose. This command will download the necessary images and spin up your containers.
bash docker-compose up -d
Step 4: Access your dashboard
After the command finishes, your automation platform is live. You can now access your interface to begin building your workflows:
- n8n Dashboard: Open your web browser and go to http://YOUR-SERVER-IP:5678
- Verify Ollama: Ollama will be listening on port 11434. n8n will connect to this port internally to send requests to your AI models.
How to Connect n8n to Your Local Ollama Engine
Once both containers are running side-by-side, the next step is to introduce them to each other. Because Docker Compose places all services on the same private network, they can communicate directly using their container names, no IP addresses or complex routing required.
Run n8n on a VPS offers two ways to reach Ollama: a flexible HTTP Request node for full manual control, or the built-in AI nodes for a faster, more integrated experience. Below, we’ll set up the connection and explore both methods.
Method 1: The Direct Route, Using the HTTP Request Node
This approach gives you complete, low-level control over every detail of your AI call. You manually build the request to Ollama’s API, choosing exactly what goes into the request body. Use this when you need custom parameters, special headers, or fine-tuned behavior that standard nodes can’t offer.
Method 2: The Smart Route — Using Built-in AI Nodes
This is the fastest and cleanest option. n8n’s native AI nodes (like LLM Chain, AI Agent, and Chat Model) come with Ollama support baked in. Simply pick Ollama as your model provider, point it to the right URL, and select your model from the list. Everything integrates seamlessly with n8n’s AI ecosystem, perfect for most workflows.
The Magic of Docker Networking, Why http://ollama:11434 Works
Here’s the elegant part: since both containers share the same Docker network, n8n reaches Ollama by its container name instead of localhost. The URL becomes http://ollama:11434, and Docker handles all the routing automatically. This is exactly why Docker Compose is so powerful, your services find each other by name, effortlessly.
Creating Your Ollama Credential in n8n
To let n8n remember the connection permanently, you’ll save it as a credential once and reuse it everywhere. Follow this path:
- Go to Settings → Credentials → Add Credential
- Select Ollama from the list
- Enter the Base URL: http://ollama:11434
- Save—and now every AI node in n8n can use this credential instantly.
Smart Form Routing: AI-Powered Customer Inquiry Classification
This workflow transforms your standard contact form into an intelligent routing engine. Instead of manual triage, the AI analyzes every incoming inquiry in real-time, instantly identifying whether a customer needs sales assistance, technical support, or partnership discussions.
By automatically directing data to the appropriate Slack channel, ticketing system, or email, this setup drastically reduces response times and ensures each message reaches the right expert immediately.
You can configure this by chaining a Webhook (to capture data), an HTTP Request node (to query Ollama), and a Switch node (to handle the routing).

Classification Prompt:
Classify the following customer request into ONE of these categories:
– sales (pricing inquiry, purchase, quote)
– support (errors, technical support, not working)
– partnership (collaboration, partners, affiliation)
– other (doesn’t belong to above categories)
Respond with exactly 1 word: sales, support, partnership, or other.
Content: {{ $json.body.message }}
Pro-Tips for Production: Scaling Your n8n + Ollama Automation
Now that your n8n and Ollama stack is operational, the real work begins: turning a basic setup into a production-ready automation engine. Working with local AI models comes with unique hurdles, from response latency to unpredictable formatting. Here are the essential tips o run ollama +n8n in a VPS and ensure your workflows remain stable, accurate, and lightning-fast.
1. Bulletproofing Your Workflows (Error Handling)
Don’t let a temporary model hiccup or a slow server response break your entire chain of automation. Build resilience into your system to ensure it keeps running even when things get bumpy.
| Technique | Goal | Action Plan |
| Smart Retries | Bypass transient lag | Enable “Retry on Fail” in your HTTP Request node; set it to 2-3 retries with a 5-second buffer. |
| Error Triggers | Instant notification | Build a secondary “Error Trigger” workflow that sends a Telegram or Email alert when a process fails. |
| Timeout Tuning | Prevent premature drops | Increase the default timeout to 60+ seconds (or 120s for heavier models) to account for initial processing time. |
2. Mastering LLM Output (Data Formatting)
LLMs can be talkative. To make sure your data feeds cleanly into databases or other apps, you need to enforce strict structure and clean up the noise.
| Method | Purpose | Action Plan |
| JSON Enforcement | Structured data ingestion | Explicitly prompt: *”Respond only in JSON format: {“category”: “…”, “confidence”: 0.9}”* to make parsing foolproof. |
| JavaScript Scrubbing | Removing text noise | Use a “Code” node (JavaScript) to trim whitespace, force lowercase, or strip unwanted characters before saving. |
| Few-Shot Prompting | Better consistency | Avoid vague instructions. Provide 2-3 examples of the exact desired output format within your prompt. |
3. Optimizing for Speed & Scalability (Performance)
Resource management is critical when running everything on a single VPS. Use these strategies to keep your system responsive without overloading your hardware.
| Optimization | Benefit | Action Plan |
| Batch Processing | Prevent server crashes | Don’t process 50 items at once. Use “SplitInBatches” or “Loop Over Items” to process data in small, manageable chunks. |
| Right-Sizing Models | Lower memory footprint | Use lightweight models (e.g., Llama 3.2 3B or Qwen 2.5 7B) for classification/summarization; save the 70B models for deep reasoning. |
| RAM Residency | Sub-second latency | Keep Ollama running continuously. It’s slow on the first load, but subsequent calls are nearly instantaneous as the model stays in RAM. |
Summary
Learning how to run ollama+n8n on VPS transforms your customer intake process from a manual bottleneck into an efficient, automated engine. By leveraging a local LLM to analyze intent the moment a message arrives, you ensure that high-priority support issues, commercial leads, and partnership inquiries are routed to the correct teams instantly. This setup not only slashes response times but also keeps your customer communication data private and secure, all while eliminating the dependency on third-party AI APIs.
Frequently Asked Questions (FAQ)
What happens if the AI misclassifies a message?
You should always include a “Fallback” branch in your Switch node. If the AI output doesn’t match your expected categories (e.g., “sales,” “support,” “partnership”), have the workflow route that message to a generic “Review” folder or Slack channel for manual human inspection.
Do I need a high-end server to run this classification?
Not at all. Because classification tasks only require loading a small model into memory, you can comfortably run this on a Deploy Apps ,Pro plan (2GB RAM). You don’t need expensive GPUs to perform text categorization.
Can I use this workflow for languages other than English?
Yes. Local models are highly capable of multilingual analysis. Simply update your classification prompt to include the desired languages (e.g., “Classify this request which may be in English or Persian into categories: sales, support…”) and the model will adapt accordingly.
Is the output from the AI always reliable for the Switch node?
To ensure reliability, always include the phrase “Respond with exactly 1 word” in your prompt. This prevents the model from generating conversational filler text and ensures the Switch node receives a clean, predictable string to evaluate.


