Skip to content

How to Deploy OpenSearch on a VPS

Updated Nov 2026

verified on Ubuntu 26.04 · Nov 2026
We earn commissions when you shop through the links below. Full disclosure →

Self-host OpenSearch and Dashboards on a VPS with Docker Compose and Caddy HTTPS, remove the demo accounts, and snapshot and restore your indices.

Before you start
  • A VPS with 4 GB+ RAM
  • A fresh Ubuntu 26.04 server with root/sudo SSH access
  • A domain or subdomain you can point at the server
Need a box for this guide? Kamatera's free tier lets you spin one up now.Start free on Kamatera → (opens in new tab)

What you are building

OpenSearch is an Apache-2.0 search and analytics engine, a community fork of Elasticsearch, with OpenSearch Dashboards as its web UI. People use it where they might otherwise pay for Algolia or Splunk. This guide runs one node and Dashboards, puts only Dashboards on the internet behind Caddy, and keeps the REST API on the server's loopback interface.

Read this before exposing anything. The container image sets itself up with a demo security configuration. Your admin password is applied, but other demo accounts (readall, logstash, kibanaserver and more) accept their own user name as the password, and the demo TLS certificates, including the administrator client certificate, are the same in every download. The steps below remove the extra accounts, change the Dashboards service password and never publish port 9200. This is a hardened single node, not a production cluster with your own certificates.

Server sizing

Plan for 4 GB of RAM. On the catalog's test box the stack measured about 1.8 GB of memory idle and about 5 GB of disk before any real data. Index size is what grows your disk.

Prepare the server

Update the system and install the tools this guide uses:

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y curl openssl ufw dnsutils

If you're logged in as root, create a non-root sudo user and continue as that user:

adduser deploy
usermod -aG sudo deploy

Open SSH and the two ports the reverse proxy needs:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable

A published Docker port goes around ufw, so the Compose file below decides what is reachable: OpenSearch gets no public port of its own.

Where to host itaffiliate disclosure
Hetzner Cloudrun it on
4 vCPU · 8 GB RAM · 160 GB SSD · $42.59/mo
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
1 vCPU · 8 GB RAM · 20 GB SSD · $24.00/mo
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
4 vCPU · 8 GB RAM · 160 GB SSD · $48.00/mo
Deploy on DigitalOcean → (opens in new tab)

Paid link — we earn a commission if you shop through it.

Install Docker

If Docker isn't on the server yet, the convenience script installs Docker Engine and the Compose plugin (the Docker and Compose on Ubuntu guide covers the details):

command -v docker >/dev/null || curl -fsSL https://get.docker.com | sudo sh
sudo docker compose version

Configure the stack

OpenSearch needs a higher vm.max_map_count than the Linux default on many systems. Set it now and keep it across reboots:

echo 'vm.max_map_count=262144' | sudo tee /etc/sysctl.d/99-opensearch.conf
sudo sysctl -p /etc/sysctl.d/99-opensearch.conf

Create the project and the secrets. Replace search.example.com with your hostname. The Aa1- prefix satisfies the password rules of the demo installer:

mkdir -p ~/opensearch/snapshots && cd ~/opensearch
DOMAIN=search.example.com
[ -f .env ] || ( umask 077
  { echo "DOMAIN=$DOMAIN"
    echo "OPENSEARCH_INITIAL_ADMIN_PASSWORD=Aa1-$(openssl rand -hex 16)"
    echo "DASHBOARDS_PASSWORD=Aa1-$(openssl rand -hex 16)"
  } > .env )
( umask 077; . ./.env; echo "user = \"admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD\"" > curlrc )
sudo chown 1000:1000 snapshots

snapshots is where backups will be written; the container runs as user 1000.

cd ~/opensearch
cat > docker-compose.yml <<'EOF'
services:
  opensearch:
    image: opensearchproject/opensearch:3.9.0
    restart: unless-stopped
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - path.repo=/usr/share/opensearch/snapshots
      - OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD}
      - DASHBOARDS_PASSWORD=${DASHBOARDS_PASSWORD}
    ulimits:
      memlock: { soft: -1, hard: -1 }
      nofile: { soft: 65536, hard: 65536 }
    volumes:
      - opensearch_data:/usr/share/opensearch/data
      - ./snapshots:/usr/share/opensearch/snapshots
    ports:
      - 127.0.0.1:9200:9200
  dashboards:
    image: opensearchproject/opensearch-dashboards:3.9.0
    restart: unless-stopped
    environment:
      OPENSEARCH_HOSTS: '["https://opensearch:9200"]'
      OPENSEARCH_USERNAME: kibanaserver
      OPENSEARCH_PASSWORD: ${DASHBOARDS_PASSWORD}
    depends_on: [opensearch]
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports: ["80:80", "443:443"]
    environment:
      DOMAIN: ${DOMAIN}
    volumes: ["./Caddyfile:/etc/caddy/Caddyfile:ro", "caddy_data:/data"]
    depends_on: [dashboards]
volumes:
  opensearch_data:
  caddy_data:
EOF
cat > Caddyfile <<'EOF'
{$DOMAIN} {
    reverse_proxy dashboards:5601
}
EOF

Start OpenSearch and remove the demo accounts

Start only the search node first:

cd ~/opensearch
sudo docker compose up -d opensearch
code=000
for i in $(seq 1 60); do
  code=$(curl -sk -K curlrc -o /dev/null -w '%{http_code}' https://127.0.0.1:9200/_cluster/health)
  [ "$code" = 200 ] && break
  sleep 5
done
echo "OpenSearch answered HTTP $code"; [ "$code" = 200 ]

Now write a script that replaces the internal user list with just two accounts: admin and the kibanaserver service account, each with your own password. Keep it, because a restore onto an empty data volume needs it again. It uses the securityadmin.sh tool shipped in the image:

cd ~/opensearch
cat > lock-users.sh <<'EOF'
#!/bin/sh
set -e
cd "$(dirname "$0")"
sudo docker compose exec -T opensearch bash -s <<'IN'
set -e
cd /usr/share/opensearch
T=plugins/opensearch-security/tools
admin=$(bash $T/hash.sh -env OPENSEARCH_INITIAL_ADMIN_PASSWORD | tail -n 1)
kib=$(bash $T/hash.sh -env DASHBOARDS_PASSWORD | tail -n 1)
cat > /tmp/internal_users.yml <<YML
_meta:
  type: "internalusers"
  config_version: 2
admin:
  hash: "$admin"
  reserved: true
  backend_roles:
  - "admin"
kibanaserver:
  hash: "$kib"
  reserved: true
YML
bash $T/securityadmin.sh -f /tmp/internal_users.yml -t internalusers -icl -nhnv \
  -cacert config/root-ca.pem -cert config/kirk.pem -key config/kirk-key.pem
IN
EOF
chmod +x lock-users.sh
./lock-users.sh

Prove the demo logins are gone: every line must say 401.

sleep 5
bad=0
for u in anomalyadmin kibanaserver kibanaro logstash readall snapshotrestore; do
  code=$(curl -sk -o /dev/null -w '%{http_code}' -u "$u:$u" https://127.0.0.1:9200/_plugins/_security/authinfo)
  echo "$u:$u -> $code"; [ "$code" = 401 ] || bad=1
done
[ $bad = 0 ]

Start Dashboards

cd ~/opensearch
sudo docker compose up -d
sudo docker compose ps

HTTPS and the domain

Create an A record for your hostname pointing at the server's public IP and confirm it resolves before Caddy asks for a certificate:

dig +short search.example.com

Caddy requests the certificate once the name resolves and renews it on its own (see Automatic HTTPS with Caddy). Dashboards answers 503 while it is still starting, so the check retries:

. ~/opensearch/.env
code=000
for i in $(seq 1 60); do
  code=$(curl -s -K ~/opensearch/curlrc -o /dev/null -w '%{http_code}' "https://$DOMAIN/api/status")
  [ "$code" = 200 ] && break
  sleep 5
done
echo "Dashboards over HTTPS answered $code"; [ "$code" = 200 ]

First login

Open https://search.example.com, sign in as admin with OPENSEARCH_INITIAL_ADMIN_PASSWORD from ~/opensearch/.env, and store it in your password manager. Create a separate user and role for each person or application instead of sharing admin. The environment variable only seeds the first start; editing .env alone does not change the password.

lock-users.sh replaces the whole internal user list. Once you have added users of your own, add them to its YAML before running it again, or they are deleted.

Index a test document and create an index pattern, which gives the backup something real to restore:

cd ~/opensearch
. ./.env
curl -sk -K curlrc -X PUT 'https://127.0.0.1:9200/notes/_doc/1?refresh=true' \
  -H 'Content-Type: application/json' -d '{"msg":"restore me"}'; echo
curl -sf -K curlrc -X POST "https://$DOMAIN/api/saved_objects/index-pattern/notes-pattern?overwrite=true" \
  -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d '{"attributes":{"title":"notes*"}}'; echo

Backups

Copying the data directory of a running node is not a backup. Use the snapshot API with a filesystem repository (the path.repo setting above). This registers it and snapshots your indices plus the .kibana* indices that hold Dashboards saved objects. The audit log and query-insight indices that OpenSearch creates for itself are left out, because a new node already has its own and the restore would collide with them:

cd ~/opensearch
curl -sk -K curlrc -X PUT https://127.0.0.1:9200/_snapshot/local \
  -H 'Content-Type: application/json' \
  -d '{"type":"fs","settings":{"location":"/usr/share/opensearch/snapshots"}}'; echo
SNAP=snap-$(date +%Y%m%d-%H%M%S)
curl -sk -K curlrc -X PUT "https://127.0.0.1:9200/_snapshot/local/$SNAP?wait_for_completion=true" \
  -H 'Content-Type: application/json' \
  -d '{"indices":"*,-.*,-security-auditlog-*,-top_queries-*,.kibana*","include_global_state":false}' | tee /tmp/snap.json; echo
grep -q '"state":"SUCCESS"' /tmp/snap.json

Then pack the repository together with your configuration, and copy the archive off the server. It contains your passwords:

cd ~/opensearch
( umask 077; sudo tar czf - snapshots .env curlrc docker-compose.yml Caddyfile lock-users.sh > ~/opensearch-backup.tar.gz )
ls -lh ~/opensearch-backup.tar.gz

The snapshot leaves out the security index, so users and roles you add are not in it. Export them separately with securityadmin.sh -backup if you have any.

Restore

This restores onto an empty data volume, as on a replacement server. It deletes the current data, so only run it once the archive is safe. On a new server, do the preparation, Docker and vm.max_map_count steps, then unpack into ~/opensearch.

The block checks the archive first and stops at the first error. It registers the repository again and restores before starting Dashboards, so nothing has created a .kibana index in the way. With no indices field, the restore brings back everything in the snapshot:

(
  set -e
  cd ~/opensearch
  tar tzf ~/opensearch-backup.tar.gz >/dev/null
  sudo docker compose down
  sudo docker volume rm -f opensearch_opensearch_data
  sudo rm -rf snapshots
  sudo tar xzf ~/opensearch-backup.tar.gz
  sudo docker compose up -d opensearch
  code=000
  for i in $(seq 1 60); do
    code=$(curl -sk -K curlrc -o /dev/null -w '%{http_code}' https://127.0.0.1:9200/_cluster/health) || true
    [ "$code" = 200 ] && break
    sleep 5
  done
  [ "$code" = 200 ]
  ./lock-users.sh
  curl -skf -K curlrc -X PUT https://127.0.0.1:9200/_snapshot/local \
    -H 'Content-Type: application/json' \
    -d '{"type":"fs","settings":{"location":"/usr/share/opensearch/snapshots"}}'
  echo
  SNAP=$(curl -skf -K curlrc 'https://127.0.0.1:9200/_cat/snapshots/local?h=id&s=end_epoch' | tail -n 1 | tr -d ' ')
  [ -n "$SNAP" ]
  curl -skf -K curlrc -X POST "https://127.0.0.1:9200/_snapshot/local/$SNAP/_restore?wait_for_completion=true" \
    -H 'Content-Type: application/json' -d '{"include_global_state":false}'
  echo
  sudo docker compose up -d
  curl -sk -K curlrc https://127.0.0.1:9200/notes/_doc/1 | tee /tmp/doc.json
  echo
  grep -q 'restore me' /tmp/doc.json
)

Check the saved object came back too:

. ~/opensearch/.env
for i in $(seq 1 60); do
  curl -sf -K ~/opensearch/curlrc "https://$DOMAIN/api/saved_objects/index-pattern/notes-pattern" -o /tmp/ip.json && break
  sleep 5
done
cat /tmp/ip.json; echo; grep -q 'notes\*' /tmp/ip.json

Upgrades

Read the release notes, take a snapshot, then change both image tags in docker-compose.yml to the same version (this guide pins 3.9.0) and recreate:

cd ~/opensearch
sudo docker compose pull
sudo docker compose up -d
sudo docker compose ps

Do not plan on downgrading a data volume; go back by restoring a snapshot into the old version.

Installed from the older app-page snippet?

If you copied the install snippet from the OpenSearch page before 29 November 2026, the demo accounts are still active: logstash, readall, kibanaserver and others accept their own user name as the password. Updating the image does not remove them. The steps below delete them one by one, so users you added yourself stay, and give the kibanaserver service account a random password. If you used the guide on this page, you don't need this.

Run it once, in the folder that holds your docker-compose.yml and .env. Add sudo before docker if your user needs it:

echo "DASHBOARDS_PASSWORD=Aa1-$(openssl rand -hex 16)" >> .env
. ./.env
api() { docker compose exec -T opensearch curl -sk --cert config/kirk.pem --key config/kirk-key.pem -H 'Content-Type: application/json' "$@" </dev/null; echo; }
URL=https://localhost:9200/_plugins/_security/api/internalusers
for u in anomalyadmin kibanaro logstash readall snapshotrestore; do api -X DELETE $URL/$u; done
api -X PUT $URL/kibanaserver -d "{\"password\":\"$DASHBOARDS_PASSWORD\"}"
sed -i '/OPENSEARCH_HOSTS:/a\      OPENSEARCH_PASSWORD: ${DASHBOARDS_PASSWORD}' docker-compose.yml
docker compose up -d

Wait until Dashboards loads again, then check that every line says 401:

for u in anomalyadmin kibanaserver kibanaro logstash readall snapshotrestore; do
  echo "$u -> $(curl -sk -o /dev/null -w '%{http_code}' -u "$u:$u" https://localhost:9200/_plugins/_security/authinfo)"
done

The change is stored in the data volume. If you delete that volume, the demo accounts come back, so move to the current snippet or this guide. The app-page snippet publishes ports 9200, 9600 and 5601; close them in your provider's firewall if they don't need to be reachable from the internet.

Troubleshooting

cd ~/opensearch && sudo docker compose logs --tail=100 opensearch dashboards caddy

A log line about max virtual memory areas means the sysctl step was skipped. A password rejected at first start must have upper case, lower case, a digit and a special character, and not be guessable.

Next steps

Compare providers in Best VPS for self-hosting.

Next steps

Common questions

How long does it take to follow "How to Deploy OpenSearch on a VPS"?

We estimate about 45 minutes of hands-on time for "How to Deploy OpenSearch on a VPS"; this is an editorial estimate, not a measurement.

Was the "How to Deploy OpenSearch on a VPS" guide tested?

The "How to Deploy OpenSearch on a VPS" guide was verified end-to-end on Ubuntu 26.04 (Nov 2026).

Analytics cookies only (Google Analytics, PostHog). No ad networks, no cross-site tracking. See our privacy policy.