SearXNG: Self-Hosted Private Search Aggregator

Self-host SearXNG, a metasearch engine aggregating results from multiple engines. Ad-free results and JSON API for LLM integration. | Preview Image | Coders' Compass Publishing
Self-host SearXNG, a metasearch engine aggregating results from multiple engines. Ad-free results and JSON API for LLM integration.

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.

1
docker --version

You should see output similar to:

1
Docker version 29.0.1, build eedd9698e9

Verify Docker Compose is installed:

1
docker compose version

Expected output:

1
Docker 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:

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

  searxng:
    container_name: searxng
    image: docker.io/searxng/searxng:latest
    restart: unless-stopped
    networks:
      - searxng
    ports:
      - "8080:8080"
    volumes:
      - ./data/searxng:/etc/searxng:rw
    environment:
      - SEARXNG_BASE_URL=http://localhost:8080/
      - UWSGI_WORKERS=2
      - UWSGI_THREADS=2
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    logging:
      driver: "json-file"
      options:
        max-size: "1m"
        max-file: "1"

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

1
docker 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:

1
tailscale 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