Journal indexDockup / field note
Note / self-host-typesense

How to Self-Host Typesense in 2026: API Keys, Collections and Backups

Self-host Typesense with correct ports, persistent storage, HTTPS, secrets, backups and upgrade checks. Learn how to fix when the command omits --data-dir.

The shortest Typesense demo proves that a process listens on port 8108. Production needs stronger evidence. It must pass this scenario even after the container has been replaced: define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint.

Typesense is being deployed for a clear purpose: instant search engine with a straightforward HTTP API. Its most common deployment trap is that the command omits --data-dir or health checks hit the wrong path, so public URL handling and durable state receive the same attention as image startup.

Reduce the authority held by Typesense

The application-specific security risk is embedding the bootstrap admin API key in browser code. The operational answer is to never ship the bootstrap administrator key to the browser; generate scoped search keys for public clients. Finish bootstrap through a restricted route and remove temporary setup access immediately afterward.

Treat TYPESENSE_API_KEY according to its Typesense role: keep sensitive values out of Git, document rotation effects and never substitute a public example in production. Give the Typesense process only its documented mounts and dependency routes; avoid host root and Docker socket access. Log failed authentication and configuration errors, but redact tokens, connection strings and user content.

The production shape of Typesense

The Typesense HTTP process listens on 8108; keep that port on the application network and publish only the platform route. The local runtime requirement is disk for collections and enough memory for the active dataset. Document the expected capacity, ownership and failure mode rather than leaving it as an image default.

Write the boundary down as a short contract: who owns the requirement, which credential is used, what timeout is acceptable and how failure appears. Then run this transaction: define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint. Observe RAM needed for active indexes, bulk-import size, disk persistence and cluster replication traffic during the run, because that workload gives a more useful starting size than an idle container.

Container settings worth reviewing

The first container should be easy to delete and recreate. Keep data off the writable layer, bind port 8108 only where the proxy can reach it and pass configuration at runtime.

docker run -d \
  --name typesense \
  --restart unless-stopped \
  -p 127.0.0.1:8108:8108 \
  -v typesense-data:/data \
  -e TYPESENSE_API_KEY=replace-with-a-long-random-value \
  -e TYPESENSE_DATA_DIR=/data \
  typesense/typesense:latest

Pin the image after the initial test. Read the earliest startup error rather than the final restart message, verify each mount with docker inspect, and follow logs while you define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint. That sequence distinguishes a bad image command from a dependency or permission problem.

The Typesense release gate

A release candidate for Typesense earns traffic by completing a fixed scenario: define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint. Capture the image digest, effective non-secret configuration, public origin and timestamps for that scenario. The test data should be disposable but realistic enough to exercise the same path as users.

Run it after replacing the runtime, then rebuild the service from the data directory and, for clusters, consistent snapshots of every node. Recovery passes when collections, aliases, overrides and synonyms return and the same query produces an equivalent ranked result. Compare resource measurements for RAM needed for active indexes, bulk-import size, disk persistence and cluster replication traffic with the prior release and investigate meaningful drift before promotion.

Finally, exercise this controlled failure: submit harmless input near the resource or format limit associated with this boundary: the command omits --data-dir or health checks hit the wrong path. Verify that Typesense explains the failure, does not damage existing state and resumes after the valid condition returns. Save a redacted log excerpt and the recovery time. Together these checks cover behavior, durability and operability rather than just process uptime.

Route Typesense without lying about HTTPS

The public boundary for Typesense should be one canonical hostname, automatic TLS and one internal target on 8108. Route the HTTP API while keeping peering ports private so clients return to an address the service recognizes.

If the acceptance transaction fails, classify the first error. DNS, certificate and 502 problems belong to the TLS validation checklist. The condition “the command omits --data-dir or health checks hit the wrong path” belongs to the application side after a request has successfully reached Typesense.

Rehearse the risky Typesense change

Use define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint as the Typesense smoke test after every deployment. Its supporting metrics are RAM needed for active indexes, bulk-import size, disk persistence and cluster replication traffic; alert where those resources approach a point that degrades the user action.

The main change risk is that collection schema changes and snapshots deserve a rehearsal because an image rollback cannot undo a data-format change. A safe release starts from a restorable snapshot and validates any one-way state change before traffic moves. When the command omits --data-dir or health checks hit the wrong path, keep the failed container long enough to read its configuration and first error.

Prove Typesense survives replacement

List the state before the first real record is created: the data directory and, for clusters, consistent snapshots of every node. Mount /data before bootstrap, write harmless sample data and replace the container to prove that path is actually persistent. Confirm the mount by writing harmless data, replacing Typesense and reading it back.

Snapshots are valuable for quick rollback, but an independent backup is needed when the host or volume disappears. Restore into an empty environment with the pinned image and verify that collections, aliases, overrides and synonyms return and the same query produces an equivalent ranked result. Use persistent volumes and snapshots to keep those two recovery mechanisms distinct.

A Dockup deployment still needs an Typesense acceptance test

Routing, certificates, service replacement and attached storage are reasonable automation targets. Dockup handles those for Typesense and can provision the related managed database or connect to services on a customer's own server.

What it should not invent is the Typesense trust policy. After deployment, route the HTTP API while keeping peering ports private, enforce this boundary — never ship the bootstrap administrator key to the browser; generate scoped search keys for public clients — and verify the result of this scenario: define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint. The outcome is one-click infrastructure with an application-specific acceptance test.

Frequently asked questions

What does Typesense need for a production deployment?

Route the Typesense container on port 8108 through one HTTPS origin. The local runtime requirement is disk for collections and enough memory for the active dataset. Do not call Typesense ready until you can define a collection schema, import sample documents, run typo search, facets and filters, then test the health endpoint.

Which Typesense data belongs in a backup?

Persist /data and include the data directory and, for clusters, consistent snapshots of every node in the same recovery manifest. A clean Typesense restore passes only when collections, aliases, overrides and synonyms return and the same query produces an equivalent ranked result.

Does Typesense require HTTPS behind a reverse proxy?

Use HTTPS for the public Typesense origin and keep port 8108 on the internal route. Apply the Typesense setting correctly: route the HTTP API while keeping peering ports private. For Typesense, HTTPS protects credentials or user content in transit and keeps origin-sensitive client behavior consistent.

How should a Typesense upgrade be tested?

Restore current Typesense state into an isolated deployment, apply the candidate version and repeat its acceptance transaction. Pay particular attention because collection schema changes and snapshots deserve a rehearsal because an image rollback cannot undo a data-format change. Keep the previous Typesense image until its data-migration and rollback boundary are understood.