---
title: "Deploy SearXNG Search API — Private Metasearch for AI"
description: "Self-hosted search API for AI agents — JSON, no API keys, Valkey"
category: "AI/ML"
url: https://railway.com/deploy/searxng-valkey-ai-search
---

# Deploy SearXNG Search API — Private Metasearch for AI

Self-hosted search API for AI agents — JSON, no API keys, Valkey

**[Deploy SearXNG Search API — Private Metasearch for AI on Railway](https://railway.com/template/searxng-valkey-ai-search)**

- **Creator:** SilverBanana
- **Category:** AI/ML
- **Total deploys:** 6

## Template content

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2.1
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

### SearXNG https://docs.searxng.org/_static/searxng-wordmark.svg

- **Source:** praveen-ks-2001/searxng-railway-template

## Documentation

# Deploy and Host SearXNG on Railway

SearXNG is a privacy-first, open-source metasearch engine — a federated search aggregator that pulls results from Google, Bing, DuckDuckGo, and 200+ other sources without tracking you, logging your queries, or serving ads. With its JSON API enabled, it doubles as a free, unlimited web-search backend for AI agents and automation, so your LLM tools can search the live web without paying for the Google or Bing API.

This template deploys SearXNG with a Valkey cache, JSON API pre-enabled, and the cryptographic secret generated for you.

---

## What This Template Deploys

| Service | Purpose |
| --- | --- |
| **SearXNG** | The metasearch engine, web UI, and JSON search API on port `8080` |
| **Valkey** | In-memory cache for rate limiting and request state |

Both services run on Railway's private network — Valkey is never exposed publicly. Valkey is the actively maintained successor to Redis, which SearXNG has deprecated in favour of it.

---

## About Hosting SearXNG

SearXNG proxies your searches across many engines and returns aggregated results with no profiling and no query logging. Self-hosting it means the aggregation happens on infrastructure you control rather than a public instance that could be rate-limited, monitored, or offline when you need it.

The bigger reason to run your own is AI. With `json` added to its output formats, SearXNG becomes a drop-in web-search tool for n8n, LangChain, LiteLLM, Flowise, and custom agents — real-time search for your LLM stack without a per-query bill from a commercial search API. This template enables the JSON API out of the box.

There is one configuration subtlety that trips most deployments: SearXNG reads its config from `settings.yml` baked into the image. If you mount a volume at `/etc/searxng`, it shadows that file and the API returns 403 Forbidden. This template deliberately bakes config into the image and mounts no volume there, so the JSON API works on first deploy.

Typical cost: **~$5/month** on Railway's Hobby plan for both services — flat, with no per-search charges ever.

---

## How It Compares

| | SearXNG (self-hosted) | Google Custom Search API | Bing Web Search API | Brave Search API |
| --- | --- | --- | --- | --- |
| Cost model | Flat ~$5/month infra | Per 1,000 queries | Per 1,000 queries | Per 1,000 queries |
| Free tier | Unlimited | 100 queries/day | Retired | Limited |
| Query logging | None | Yes | Yes | Minimal |
| Sources | 200+ engines aggregated | Google index only | Bing index only | Brave index only |
| JSON API | Yes | Yes | Yes | Yes |
| API key required | No | Yes | Yes | Yes |
| Data ownership | Full | None | None | None |

SearXNG aggregates many engines at once for a flat cost, where the commercial APIs each expose a single index and bill per query. For AI agents that search frequently, the per-query model is where costs quietly escalate.

---

## Deploy in Under 5 Minutes

1. Click **Deploy on Railway** and wait for both services to build (~2 minutes)
2. Confirm `SEARXNG_SECRET` (the cryptographic key) is set — the template generates one automatically
3. Set `SEARXNG_BASE_URL` to your Railway public domain
4. Open the domain to use the search UI immediately — no login required
5. For AI use, append `?q=your+query&format=json` to the search endpoint and consume the JSON

No Docker knowledge, no manual `settings.yml` editing, no volume to configure.

---

## Common Use Cases

- **Web search for AI agents** — give Claude, GPT, or Llama real-time search through the JSON API without paying for commercial search API access
- **n8n and Flowise automation** — drop the SearXNG URL into an HTTP Request node as a free, unlimited search backend
- **Private search engine** — search the web without tracking, query logging, or ads, from a domain you own
- **Search engine proxy** — reach engines your ISP or network blocks, with the request originating from your server
- **RAG pipelines** — feed fresh web results into retrieval-augmented generation instead of relying on stale training data
- **Research and monitoring tools** — script multi-engine searches and parse structured JSON results programmatically

---

## Configuration

| Variable | Required | Description |
| --- | --- | --- |
| `SEARXNG_SECRET` | Required | Cryptographic secret key — generate with `openssl rand -hex 32`; template sets one automatically |
| `SEARXNG_BASE_URL` | Required | Your Railway public URL, e.g. `https://your-app.up.railway.app/` |
| `SEARXNG_REDIS_URL` | Auto-injected | Valkey connection via Railway reference variable (uses the `valkey://` scheme) |
| `SEARXNG_PORT` | Pre-set | `8080` |
| `UWSGI_WORKERS` | Optional | Worker processes — raise for higher concurrency (default `4`) |
| `UWSGI_THREADS` | Optional | Threads per worker (default `4`) |
| `SEARXNG_LIMITER` | Optional | Set `true` to enable bot/rate-limit protection on public instances |
| `SEARXNG_IMAGE_PROXY` | Optional | Set `true` to proxy image results for extra privacy |

> **The JSON API depends on not mounting a volume at `/etc/searxng`.** Config is baked into the image. Mounting a volume there shadows `settings.yml`, and search requests return 403 Forbidden. Leave that path unmounted.

> **Set a strong `SEARXNG_SECRET`.** It secures the instance cryptographically. The template generates one; if you replace it, use `openssl rand -hex 32`.

---

## Dependencies for SearXNG Hosting

- Railway account — Hobby plan (~$5/month) covers both services
- Nothing else — no API keys, no external accounts, no model provider required
- Optional: an AI tool (n8n, LangChain, LiteLLM, Flowise) to consume the JSON API

### Deployment Dependencies

- [SearXNG GitHub Repository](https://github.com/searxng/searxng)
- [SearXNG Documentation](https://docs.searxng.org/)
- [SearXNG Settings Reference](https://docs.searxng.org/admin/settings/index.html)
- [Railway Volumes Documentation](https://docs.railway.com/volumes)

### Implementation Details

The template runs the official `docker.io/searxng/searxng:latest` image on port `8080` alongside Valkey for caching and rate limiting. The two communicate over Railway's private network, and Valkey is never publicly exposed. SearXNG has moved from Redis to Valkey, so this template uses Valkey with the `valkey://` connection scheme rather than the deprecated Redis configuration.

`settings.yml` is baked into the image with the `json` output format enabled, which is what makes the instance usable as an API. No volume is mounted at `/etc/searxng`, because a mount there shadows the baked-in config and causes 403 responses on search — a common failure in other SearXNG deployments. The cryptographic `SEARXNG_SECRET` is generated at deploy time.

Because SearXNG holds no persistent user data — the Valkey cache is ephemeral and rebuilds itself — there is nothing to back up beyond your configuration, and redeploys are clean. Note that some engines (Google especially) rate-limit requests from cloud IPs; if a specific engine returns empty results, check its status in the preferences page and rely on the many others in the pool.

---

## Frequently Asked Questions

**Do I need any API keys?** No. SearXNG aggregates public search engines directly, so there are no keys, accounts, or provider sign-ups. Deploy and it works.

**How do I use it with AI agents?** Append `format=json` to the search endpoint (`/search?q=query&format=json`) and point your tool at that URL. It works out of the box with n8n, LangChain, LiteLLM, and Flowise as a free web-search backend.

**Why does the JSON API return 403?** Almost always because a volume is mounted at `/etc/searxng`, which shadows the baked-in `settings.yml`. This template mounts no volume there, so the API works — leave that path unmounted.

**Why Valkey instead of Redis?** SearXNG has deprecated Redis in favour of Valkey, its actively maintained successor. This template uses Valkey with the current `valkey://` scheme, keeping the deployment aligned with upstream.

**Is my search history stored anywhere?** No. SearXNG does not profile users or log queries, and the Valkey cache is ephemeral. Nothing about your searches is persisted.

**Do all search engines always work?** Most do, but some (notably Google) rate-limit cloud-provider IPs and may intermittently return empty results. SearXNG pools 200+ sources, so results stay strong; check the Engines tab in preferences if one misbehaves.

**Can I customise which engines it uses?** Yes. Engine selection, safe-search level, and themes are all configurable. Adjust them per-search in the UI, or bake defaults into the template's `settings.yml`.

---

## Why Deploy SearXNG on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying SearXNG on Railway you get a private metasearch engine and a free, unlimited search API in one click — JSON pre-enabled for AI agents, Valkey caching over a private network, automatic HTTPS, and the config-shadowing pitfall already handled. Give your LLM tools real-time web search without a commercial API bill, and keep your searches on infrastructure you own.

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/searxng-valkey-ai-search
