SSD Nodes Learn Hosting plans →
Guides Matt ConnorBy Matt Connor

Self-host Wikipedia on a VPS with Kiwix

Run kiwix-serve 3.8.2 on a VPS with Docker Compose: pick a Wikipedia ZIM that fits your disk, fix UID 1001 permissions, and swap ZIM files with no restart.

Self-host Wikipedia on a VPS: the short answer

To self-host Wikipedia, download one ZIM file and serve it with kiwix-serve in Docker. A ZIM file is a single compressed archive that holds a whole website, and the Kiwix project publishes Wikipedia in that format. On a VPS the setup is one Compose service and one data folder, which holds the ZIM and a library.xml file that tells the server what to load.

The install is short. The real work is in the details around it: disk size, folder ownership, safe updates and who can reach the server. This guide covers each one.

Everything below uses the image ghcr.io/kiwix/kiwix-serve:3.8.2. kiwix-tools 3.8.2 was released on 2 March 2026, and it is still the latest release on 1 December 2026. Every flag and default in this guide comes from that release's source and docs. You need Docker with the Compose plugin. If the VPS is bare, start with the Docker Compose basics for a VPS.

How big is Wikipedia offline?

Kiwix packs English Wikipedia in several flavours. These are the newest English files on the official download listing on 1 December 2026, with sizes taken from each file's exact byte count.

ChartEnglish Wikipedia ZIM files on 1 December 2026
The data behind this chart
[
  {
    "label": "all_maxi 2026-08",
    "gib_exact": 118.7,
    "gb_exact": 127.4,
    "gb_for_swap": 254.8,
    "pct_smaller_than_maxi": 0
  },
  {
    "label": "all_nopic 2026-06",
    "gib_exact": 49.1,
    "gb_exact": 52.7,
    "gb_for_swap": 105.4,
    "pct_smaller_than_maxi": 59
  },
  {
    "label": "all_mini 2026-09",
    "gib_exact": 13.4,
    "gb_exact": 14.4,
    "gb_for_swap": 28.8,
    "pct_smaller_than_maxi": 89
  },
  {
    "label": "top_maxi 2026-09",
    "gib_exact": 6.5,
    "gb_exact": 7.0,
    "gb_for_swap": 14.0,
    "pct_smaller_than_maxi": 95
  },
  {
    "label": "100_full 2026-11",
    "gib_exact": 0.34,
    "gb_exact": 0.36,
    "gb_for_swap": 0.73,
    "pct_smaller_than_maxi": 99.7
  }
]

The listing prints sizes in binary units and rounds them. It shows the full file as "119G", which means 119 GiB (gibibytes, units of 1,073,741,824 bytes). The exact size is 118.7 GiB. VPS plans usually quote decimal GB, and in those units the same file is 127.4 GB. Plan in the units your provider bills.

What each flavour holds:

  • all_maxi: the default full version. Every article, with images.
  • all_nopic: full articles without images. It is 59% smaller than all_maxi.
  • all_mini: only the introduction and the infobox of each article. It is 89% smaller than all_maxi.
  • top_maxi: a selection of the best 50,000 articles, with images.
  • 100_full: the top one hundred articles, with pictures and videos. Use it to test your setup. It is not Wikipedia as a whole.

All the all_ files include a full-text search index.

Two more facts change your planning. First, Kiwix has no incremental updates for ZIM files, so every refresh is a full new download of the whole file. Second, the files do not all update on one schedule. On 1 December 2026 the newest all_maxi is dated 2026-08, the newest all_nopic 2026-06 and the newest 100_full 2026-11. Sizes move too. The February 2026 all_maxi was listed at 115G, and the newest top_maxi is smaller than the June one. The listing keeps only about two dated files per variant, so an old download URL can stop working.

How much disk does each Wikipedia ZIM need?

The gb_for_swap column is twice the exact file size. That is the space you need to keep the old and the new file side by side while you switch, which is how this guide updates without downtime. It is plain arithmetic, not a Kiwix requirement, and it does not include the operating system, Docker images or logs.

For the full all_maxi file, that means 254.8 GB for Wikipedia alone, so a 250 GB disk is too small for a side-by-side swap. all_nopic needs 105.4 GB, and all_mini needs 28.8 GB. You can halve the need by deleting the old file before you download the new one. The site is then down for the whole download. Releases also grow over time, so leave headroom on top. Sizing storage for a VPS walks through the rest of the disk budget, and the storage VPS checklist covers what to compare when the full file pushes you toward a storage plan.

Download the ZIM on the host, not in the container

The image has a DOWNLOAD variable that fetches a ZIM when the container starts. Do not use it for Wikipedia. The 3.8.2 entrypoint runs wget $DOWNLOAD -O "$ZIM" on every start, with no resume and no checksum step. A restart can then fetch the whole file again, and a broken download starts over from zero.

Download on the host instead. Start with the small test file, so you can prove the setup in a few minutes:

sudo mkdir -p /srv/kiwix/data
cd /srv/kiwix/data
sudo wget -c https://download.kiwix.org/zim/wikipedia/wikipedia_en_100_full_2026-11.zim
sudo wget https://download.kiwix.org/zim/wikipedia/wikipedia_en_100_full_2026-11.zim.sha256
sha256sum -c wikipedia_en_100_full_2026-11.zim.sha256

sha256sum -c should print the file name followed by OK. Anything else means the file is damaged: delete it and download it again. The -c flag makes wget continue a partial file instead of starting over, which matters for a download of more than 100 GB. Run large downloads inside tmux or screen, so a dropped SSH session does not stop them.

File names change with each release. Take the current names from the Kiwix Wikipedia download listing, and fetch the matching checksum by adding .sha256 to the end of the ZIM's URL.

Why kiwix-serve listens on 8080 in Docker and 80 outside it

Guides disagree on the port because there are two defaults. The kiwix-serve program itself defaults to port 80. Its 3.8.2 help text says Port on which to listen to HTTP requests [default: 80]. The Docker image is different. Since kiwix-tools 3.4.0, the image's entrypoint script uses 8080 unless you set a PORT environment variable, and it passes that value to the program as --port. The 3.8.2 Dockerfile also declares EXPOSE 8080.

So inside the container the server listens on 8080. To move it, set PORT in the Compose file and change the published port to match. Do not add your own --port to the command, because the entrypoint already passes one.

Give UID 1001 access to the data folder

Since 3.8.0, the container no longer runs as root. In 3.8.2 the Dockerfile creates a user named user with UID 1001 and GID 1001, and switches to it. The working directory and the volume are both /data.

The image sets the owner of its own /data at build time. That does not change a host folder you mount over it. Your host folder keeps its host owner, which is root after the sudo mkdir above. UID 1001 can then read the ZIM files, but it cannot write to the folder. Reading a ZIM needs only read and traverse permission. Writing library.xml from inside the container needs write access to the folder, so give the folder to UID 1001:

sudo chown -R 1001:1001 /srv/kiwix/data

The user is fixed in the image, so you match the folder to the image. If you know the PUID and PGID pattern from other images, how PUID and PGID map container users to host files explains the same ownership problem from the other side. Pin the tag, because the UID is part of the image. The 3.8.0 Dockerfile created its user without a fixed UID. The 3.8.1 and 3.8.2 Dockerfiles set 1001 explicitly.

If you ever do set DOWNLOAD and the folder is not writable, the container exits with this message:

'/data' directory is not writable by 'user:user' (1001:1001). ZIM file(s) can not be written.

Write the Compose file

Save this as /srv/kiwix/compose.yaml:

services:
  kiwix:
    image: ghcr.io/kiwix/kiwix-serve:3.8.2
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ./data:/data
    command: ["--library", "--monitorLibrary", "--nodatealiases", "/data/library.xml"]

Each line has a reason:

  • The tag is pinned to 3.8.2. On 1 December 2026 it points to the same image as latest, but latest will move, and a new release can change the user or a default.
  • The port is published on 127.0.0.1 only. Without a host address, Docker publishes a port on every host address, and Docker's documentation warns that published ports skip ufw rules. A plain 8080:8080 would put the server on the public internet even with ufw enabled. Publishing on the loopback address means only the VPS itself can reach the port, which is all Tailscale or a reverse proxy needs. One caveat from the same documentation: in Docker releases older than 28.0.0, hosts on the same L2 network segment can still reach ports published to localhost. Check docker version on an older host.
  • The volume mounts the folder, not a single file. That matters for the update method later in this guide.
  • --library tells kiwix-serve that the argument is a library file, not a ZIM. --monitorLibrary makes it reload that file when it changes. --nodatealiases adds a short, undated name for each ZIM. Both are explained below.
  • There is no version: line. Compose treats the top-level version as obsolete and prints a warning when it is present.

The upstream README runs the image with '*.zim' as the argument, which serves every ZIM in the folder. That works, but --monitorLibrary has no effect without --library, and it gives no error to tell you so. Without a library, every update means a restart.

restart: unless-stopped brings the container back after a reboot, as long as the Docker service itself starts at boot. Starting Compose stacks on boot covers that part.

Build library.xml with kiwix-manage

The kiwix-serve image is built on the kiwix-tools image, so it also contains kiwix-manage, the tool that writes library files. The image's entrypoint always starts kiwix-serve, so override it with --entrypoint and run kiwix-manage in a throwaway container:

cd /srv/kiwix
docker compose run --rm --entrypoint kiwix-manage kiwix /data/library.xml add /data/wikipedia_en_100_full_2026-11.zim
docker compose run --rm --entrypoint kiwix-manage kiwix /data/library.xml show

add creates library.xml if it does not exist yet. show prints each book in the library with its ID. --rm deletes the throwaway container when the command ends, and docker compose run does not publish the service's ports, so it does not clash with a running server. If library.xml does not appear in /srv/kiwix/data after add, UID 1001 cannot write to the folder. Run the chown step again.

Create the library before the first start. kiwix-serve exits at startup if it cannot load the library file, so a missing library.xml gives you a container that keeps restarting.

The library stores each ZIM path relative to the folder that holds library.xml. Keep the library and the ZIM files in the same mounted folder, and the paths stay valid.

Start kiwix-serve and check it

docker compose up -d
docker compose logs kiwix
curl -s http://127.0.0.1:8080/ | head -n 5

The entrypoint prints the full command before it runs it, so the first log line should read:

/usr/local/bin/kiwix-serve --port=8080 --library --monitorLibrary --nodatealiases /data/library.xml

That line confirms the port and the flags the server actually received. The curl line should print the start of an HTML page. Connection refused means the container is not running, or it listens on a different port than the one you published. docker compose ps shows which.

To confirm the user the container runs as, run docker compose run --rm --entrypoint id kiwix. It should report UID and GID 1001, matching the Dockerfile.

Swap in a new ZIM without a restart

This is the step most guides skip. --monitorLibrary watches library.xml and reloads it when the file's modification time is newer than the version it loaded. The source checks about once a second. Two details decide whether a swap is clean.

First, the server watches the library file, not the folder. Dropping a new ZIM into /srv/kiwix/data does nothing until library.xml changes.

Second, kiwix-manage rewrites library.xml in place. It opens the existing file, empties it, then writes the new contents. A server that checks the file during that write can read a half-written library. The safer method is to build a new library under another name, then rename it over the old one. A rename inside one folder replaces the file in one step, so the server sees either the old library or the new one. This is also why the Compose file mounts the folder: a bind mount of a single file stays attached to the original file, so a renamed replacement never reaches the container.

The same steps add your first real ZIM after the test file, and later replace each release with the next one. Here the test file is replaced by the full English Wikipedia:

cd /srv/kiwix/data
sudo wget -c https://download.kiwix.org/zim/wikipedia/wikipedia_en_all_maxi_2026-08.zim
sudo wget https://download.kiwix.org/zim/wikipedia/wikipedia_en_all_maxi_2026-08.zim.sha256
sha256sum -c wikipedia_en_all_maxi_2026-08.zim.sha256
cd /srv/kiwix
sudo rm -f data/library.new.xml
docker compose run --rm --entrypoint kiwix-manage kiwix /data/library.new.xml add /data/wikipedia_en_all_maxi_2026-08.zim
sudo mv data/library.new.xml data/library.xml
docker compose logs --since 2m kiwix

The rm -f line clears a leftover file from an earlier attempt, because add adds to a library that already exists. The new library holds only the ZIMs you pass to add. To serve several files, list them all in that one add command.

In the logs, Errors encountered while loading the library. means the reload failed. The server keeps running, so fix the new library and rename again. When the logs show no errors, open the new content in a browser, then delete the old ZIM:

sudo rm /srv/kiwix/data/wikipedia_en_100_full_2026-11.zim

Until the new library has loaded, the old file is your fallback. Keep it until then.

By default, kiwix-serve names each ZIM in its URLs after the file name. A link looks like /viewer#wikipedia_en_all_maxi_2026-08/.... The next release has a new date in its file name, so it gets a new URL, and every old bookmark breaks.

--nodatealiases fixes most of this. The name reads backwards, because the flag does not remove anything. It adds a second name for each ZIM, with the trailing _YYYY-MM date removed. wikipedia_en_all_maxi_2026-08.zim is then served under its full name and also as wikipedia_en_all_maxi. When a later all_maxi file replaces it, the short name points to the new file.

The alias has limits:

  • It strips only the date. Switching flavour, from all_nopic to all_maxi for example, changes the name.
  • Upstream file names can change. The listing on 1 December 2026 holds both wikipedia_en_100_2026-08 and wikipedia_en_100_full_2026-11, and those give different aliases.
  • Two ZIMs in one library that map to the same name collide. Only one is served under it, and the server logs Path collision. Do not count on the newer file winning. Remove the old entry in the same update, which the rebuild-and-rename method above does for you.
  • Article paths inside a ZIM can change between releases, so a link to one article can break even when the ZIM name holds.

Share and bookmark the /viewer# form of a link. The kiwix-serve docs describe the /content/ URLs as a private API, and an unknown book name under /content/ returns a 404.

Keep it private with Tailscale

kiwix-serve 3.8.2 has no login or password option. Neither its help text nor its man page lists one. The only access limit it has is --ipConnectionLimit, a cap on concurrent connections per IP address, and it is unlimited by default. Anyone who can reach the port can read everything on it.

That makes a private network the right default. Tailscale is a mesh VPN that joins your devices into one private network, called a tailnet. Its Personal plan is free, and as of December 2026 it covers up to six users. Install it with the official script, then share the port:

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
sudo tailscale serve --bg 8080
tailscale serve status

tailscale serve --bg 8080 shares the local port 8080 over HTTPS, inside your tailnet only. --bg keeps it running across reboots. Serve needs HTTPS certificates enabled for your tailnet, so turn that on in your tailnet settings first. tailscale serve status should show the HTTPS address mapped to port 8080. Your tailnet's access rules still decide which devices can open it. Tailscale Serve compared with Funnel explains the difference if you later want a public link.

Going public: a reverse proxy and the bots

A public Wikipedia mirror draws crawlers, because it is a very large site full of text. kiwix-serve gives you little to work with. It has no login, its server source has no robots.txt handling, and --ipConnectionLimit caps concurrent connections rather than request rates. Put a reverse proxy in front and do the access work there.

Caddy is the shortest route. It is a web server that serves HTTPS on its own when it knows the domain name. With a DNS record for your domain pointing at the VPS, this Caddyfile serves the mirror over HTTPS:

wiki.example.com {
    reverse_proxy 127.0.0.1:8080
}

That adds TLS (transport layer security), not a login. Running Caddy as a reverse proxy on a VPS covers the install and the firewall ports. Then follow blocking AI crawlers on your own server to add a robots.txt, User-Agent blocks and rate limits in Caddy.

Two settings matter for a mirror in particular:

  • Behind a proxy, kiwix-serve sees every request arrive from the proxy, not from the visitor. The server source shows no handling of X-Forwarded-For, so a setting such as --ipConnectionLimit=6 would cap all visitors together at six connections. Rate limit in the proxy instead.
  • To serve under a path such as example.com/wiki instead of a subdomain, add --urlRootLocation=/wiki to the command. A subdomain needs no change.

Wikipedia text is licensed under Creative Commons Attribution-ShareAlike, and the Wikimedia Foundation owns its trademarks. A public mirror must keep the attribution and the licence notice, and it must not present itself as the official Wikipedia.

Upgrade the image without surprises

When a new kiwix-tools release appears on the kiwix-tools releases page, read its changelog first. Then change the tag in compose.yaml and recreate the container:

cd /srv/kiwix
docker compose pull
docker compose up -d
docker compose run --rm --entrypoint id kiwix

The last line prints the user the new image runs as. If it is no longer 1001, change the folder's owner to match before your next library update. The ZIM files and library.xml live on the host, so recreating the container loses nothing. Backing up and upgrading a Compose stack covers the general routine. For this stack, the small files are the ones to back up: compose.yaml and library.xml. You can download a current ZIM again, although the listing does not keep old releases for long.

FAQ

Which port does the Kiwix Docker image listen on?

The ghcr.io/kiwix/kiwix-serve image listens on 8080. Its entrypoint uses 8080 unless the PORT environment variable is set, a default that dates from kiwix-tools 3.4.0. The kiwix-serve program on its own defaults to port 80, which is why non-Docker installs and some guides show 80. Publish 8080, and change the port with PORT rather than by adding --port to the command.

Why does the Kiwix container say /data is not writable?

Since 3.8.0 the container runs as an unprivileged user, and in 3.8.2 that user has UID 1001 and GID 1001. A host folder mounted at /data keeps its host owner, often root, so the container can read ZIM files but cannot write library.xml or downloads there. Run sudo chown -R 1001:1001 on the host folder. The exact message, '/data' directory is not writable by 'user:user' (1001:1001), appears when the DOWNLOAD variable is set.

Can I put a password on kiwix-serve?

Not in kiwix-serve itself. Version 3.8.2 has no login or password option. The only limit it offers is --ipConnectionLimit, a per-IP cap on concurrent connections. Keep the server private with Tailscale Serve, or put it behind a reverse proxy and add authentication in the proxy.

Download and verify the new ZIM next to the old one. Build library.new.xml with kiwix-manage, listing only the files you want served, then mv it over library.xml. With --monitorLibrary, the server reloads the library without a restart. With --nodatealiases, a link such as /viewer#wikipedia_en_all_maxi/... keeps working, because the alias drops the date from the file name. Delete the old ZIM after the logs show no load errors.

How much disk does offline English Wikipedia need?

On 1 December 2026, the full English file with images, wikipedia_en_all_maxi_2026-08.zim, is 127.4 GB, which the download listing shows as 119G because it uses binary units. Without images it is 52.7 GB, and the intro-only all_mini file is 14.4 GB. Keeping the old and new files side by side during an update doubles that, so plan 254.8 GB for the full file before the operating system and Docker.

Was this article useful?