SearXNG: Self-Hosted Private Search Aggregator

Hero image for SearXNG: Self-Hosted Private Search Aggregator | Coders' Compass Publishing

Introduction

SearXNG is a free, open-source metasearch engine that aggregates results from over 70 search engines while respecting your privacy. Unlike traditional search engines, SearXNG doesn’t track your searches, build a profile on you, or serve you advertisements.

When you use popular search engines like Google or Bing, your queries are logged, analysed, and used to build an advertising profile. Even privacy-focused alternatives like DuckDuckGo are proprietary and require trust in a third party. By self-hosting SearXNG, you take complete control over your search experience. Your queries stay on your server, and you can verify exactly what the software does by examining the source code.

One particularly useful feature is SearXNG’s ability to output results as JSON. This makes it an excellent tool for integrating web search capabilities into local LLM applications like Open WebUI, with no need for API keys or worrying about rate limits.

Prerequisites

Verification

Before proceeding with the installation, verify that Docker is installed.

1docker --version

You should see output similar to:

1Docker version 29.0.1, build eedd9698e9

Verify Docker Compose is installed:

1docker compose version

Expected output:

1Docker Compose version 2.40.3

Installation

SearXNG uses Redis (or Valkey, a Redis-compatible alternative) for cacheing and rate limiting. The Docker Compose configuration below sets up both services.

Choose or create an appropriate directory, such as ~/self-hosting/searxng.

Create a docker-compose.yaml file:

 1services:
 2  redis:
 3    container_name: redis
 4    image: docker.io/valkey/valkey:8-alpine
 5    command: >-
 6      valkey-server --save 30 1
 7      --loglevel warning
 8    restart: unless-stopped
 9    networks:
10      - searxng
11    volumes:
12      - ./data/redis:/data
13    user: "1000:1000"
14    cap_drop:
15      - ALL
16    cap_add:
17      - SETGID
18      - SETUID
19      - DAC_OVERRIDE
20    logging:
21      driver: "json-file"
22      options:
23        max-size: "1m"
24        max-file: "1"
25
26  searxng:
27    container_name: searxng
28    image: docker.io/searxng/searxng:latest
29    restart: unless-stopped
30    networks:
31      - searxng
32    ports:
33      - "8080:8080"
34    volumes:
35      - ./data/searxng:/etc/searxng:rw
36    environment:
37      - SEARXNG_BASE_URL=http://localhost:8080/
38      - UWSGI_WORKERS=2
39      - UWSGI_THREADS=2
40    cap_drop:
41      - ALL
42    cap_add:
43      - CHOWN
44      - SETGID
45      - SETUID
46    logging:
47      driver: "json-file"
48      options:
49        max-size: "1m"
50        max-file: "1"
51
52networks:
53  searxng:

Note: Adjust the SEARXNG_BASE_URL environment variable to match your server’s IP address or hostname. If you’re deploying on a local network, use your server’s IP (e.g., http://192.168.0.90:8080/). The port mapping can also be customised—change 8080:8080 to something like 8090:8080 if port 8080 is already in use.

Pull the images and start the containers:

1docker compose pull && docker compose up -d

Access SearXNG at http://localhost:8080 (or your configured address).

HTTPS

On Private Tailscale Network

If you want free HTTPS without configuring certificates manually, you can use Tailscale Serve. After installing Tailscale on your server:

1tailscale serve --bg 8080

This exposes your SearXNG instance over HTTPS on your Tailscale network.

On the Public Internet With Caddy

If you want to access your SearXNG instance publicly, it is strongly recommended that you use HTTPS. You can achieve this with a reverse proxy like Caddy, especially if you have it configured with the rate-limit plugin.

Features and Use Cases

SearXNG offers several interesting advantages over traditional search engines.

Ad-Free Search Results

All search results pass through your server, which means you see the actual results with no sponsored content or advertisements. This alone makes self-hosting worthwhile. You do not need to scroll past “promoted results” to find what you’re actually looking for.

Ad-free search results showing multiple engine sources

Search results aggregated from Google, Qwant, Startpage, and DuckDuckGo. Completely ad-free.

LLM Integration via JSON API

SearXNG can output search results as JSON, making it trivial to integrate with local LLM applications. If you’re running Open WebUI or similar tools, you can use SearXNG as a web search backend without:

You can perform a (practically) unlimited number of searches through your own instance. The JSON output (look up how to enable it) includes useful metadata like which engines returned each result, relevance scores, and content snippets.

Aggregated Multi-Engine Results

Depending on your configuration, SearXNG queries multiple search engines simultaneously and combines the results. This provides several benefits:

The default configuration queries Google, Bing, DuckDuckGo, Qwant, Startpage, and many others. You can customise which engines to use through the settings interface.

Privacy Considerations

While SearXNG prevents search engines from tracking your queries directly, there’s an important caveat: your IP address is still visible to the search engines when SearXNG queries them on your behalf. This means search providers might still build a profile based on the searches coming from your server’s IP.

To mitigate this, consider one of the following approaches:

  1. Use a VPN container: Run Gluetun alongside SearXNG to route all search queries through a VPN. This masks your server’s IP address.
  2. Use a shared VPN exit node: If you have access to a VPN service with shared IP addresses, your queries will blend in with traffic from other users.

This might be overkill for most home users. The benefits of no tracking cookies, personalised advertising, or search history are already a substantial improvement over using search engines directly. It is worth partially implementing this over not implementing this at all.

Supporting the Project

SearXNG is maintained by a volunteer community. The project doesn’t appear to have a direct donation mechanism, but you can support it in other ways:

Running a public instance (if you have the resources) also helps the broader community access privacy-respecting search.

Conclusion

SearXNG provides a practical way to reclaim control over your search experience. The deployment is straightforward with Docker Compose, and the benefits are immediate: ad-free results, no tracking, and a free web search API.

SearXNG is worth considering for those who are concerned about privacy or wish to avoid advertisements. Self-hosting offers the advantage of integrating with local LLMs for web search. The configuration above should get you running in under ten minutes.

Have you set up SearXNG or another privacy-focused search solution? Share your experience in the comments.

Comments