---
title: "Deploy Typesense Ruby"
description: "official Ruby client against Railway"
category: "Analytics"
url: https://railway.com/deploy/typesense-ruby
---

# Deploy Typesense Ruby

official Ruby client against Railway

**[Deploy Typesense Ruby on Railway](https://railway.com/template/typesense-ruby)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/typesense-ruby/manifest.json

- **Creator:** onepush
- **Category:** Analytics

## Template content

### typesense-railway

- **Source:** Shinyduo/typesense-railway
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted Typesense Ruby (Open-Source Instant Search) on Railway

Typesense Ruby on this Railway listing is official `typesense/typesense:30.2` on port `8108` with a `/data` volume, `TYPESENSE_API_KEY`, and `--enable-cors`, so InstantSearch clients can query the node.

## About Hosting Typesense Ruby open-source software on Railway (self hosted Typesense template)

The image runs `typesense/typesense:30.2`, listens on `8108`, and stores snapshots in `/data`. Pass `--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors`. Pin `30.2`; future majors may change snapshot format. CORS is only for browser InstantSearch; proxy through Ruby to keep the key private.

## Why Deploy Typesense Ruby, the Algolia alternative on Railway (Railway Free Trial)

Algolia bills per search and record; Typesense is GPL-3.0 open source with flat Railway compute. The $5 GitHub trial covers a small node for most of a month.

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Typesense Ruby on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

### Railway vs Other Hosting Providers and VPS for Typesense Ruby self hosting

Railway’s private network lets Rails reach Typesense by internal hostname; a raw VPS needs manual config.

## Common Use Cases for hosted Typesense Ruby

Index Rails e-commerce product fields or API docs for typo-tolerant autocomplete; the Ruby gem handles inline indexing under a few hundred thousand records.

## Dependencies for Typesense Ruby Docker hosted on Railway

Runs official `typesense/typesense:30.2` with volume at `/data`, `TYPESENSE_API_KEY`, and `--enable-cors` on `8108`. No extra database.

### Deployment Dependencies for Managed Typesense Ruby Service (Instant Search)

Set a Railway service using `typesense/typesense:30.2`, attach volume at `/data`, set `TYPESENSE_API_KEY` to a long random string, health check on `8108`. Command: `--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors`. Size volume 2–3x RAM for snapshots. Set initial delay ≥10s; large indexes need 30s for WAL replay.

### Implementation Details for Typesense Ruby (Using Typesense official docker image)

Official image only has the Typesense binary. Flags are the config: `--data-dir /data`, `--api-key`, `--enable-cors`. Keep service private and let Ruby proxy. Mount volume at `/data`.

## How does Typesense Ruby compare against other Instant Search platforms

Where Typesense Ruby wins versus managed and OSS Instant Search stacks.

### Typesense Ruby vs Algolia (Algolia Alternative)

Algolia wins on zero ops and a polished dashboard. You pay per search request and per record stored; a small catalog doing 100k searches/day can hit $50–100/month. Typesense Ruby on Railway costs a flat compute fee, often $8–15.

### Typesense Ruby vs Elasticsearch (Elasticsearch Alternative)

Elasticsearch handles aggregations and log analytics that Typesense never will. But a single Elasticsearch node idles at 1–2 GB RAM and needs JVM tuning. Typesense uses a few hundred MB for small indexes, and the Ruby gem is three lines to working search.

### Typesense Ruby vs Meilisearch (Meilisearch Alternative)

Meilisearch is the closest competitor: open-source, Rust, in-memory, typo-tolerant, with a Ruby client. Meilisearch’s dashboard is friendlier and default ranking is more aggressive on prefixes. Typesense has a more mature `typesense-instantsearch-adapter` gem and SQL-like facet filtering. Both are excellent; Typesense edges ahead for the backend proxy pattern with Algolia’s InstantSearch.js.

### Typesense Ruby vs Pinecone (Pinecone Alternative)

Pinecone is managed vector search for RAG. Typesense is lexical instant search with optional embeddings; the official Ruby gem talks to typesense/typesense:30.2 on port 8108 with /data persistence. Choose Pinecone for pure vector SaaS; choose Typesense Ruby for typo-tolerant keyword search, facets, and GPL-3.0 control on Railway.

## How to use Typesense Ruby (the OSS Instant Search)?

Install the `typesense` gem. Set `TYPESENSE_API_KEY`, `TYPESENSE_HOST`, and `TYPESENSE_PORT` (default `8108`). Create a client:

```ruby
require 'typesense'
client = Typesense::Client.new(
  nodes: [{ host: 'localhost', port: 8108, protocol: 'http' }],
  api_key: ENV['TYPESENSE_API_KEY'],
  connection_timeout_seconds: 2
)
```

Create a collection with a schema defining fields like `title`, `tags`, and `embedding`. Index documents via `client.collections['books'].documents.create(document)`. Search with `client.collections['books'].documents.search(q: 'harry potter', query_by: 'title')`. Enable CORS with `--enable-cors` on the server if the Ruby app runs in a browser. For Rails, add an initializer that sets the client as a global constant.

## How to self host Typesense Ruby on other VPS Services (Typesense Ruby self hosting guide)

Run the Typesense server as a Docker container on any VPS. The Ruby client connects to this server over HTTP. No Ruby code runs on the server side—the server is a single binary inside the official image.

### Clone the Repository

Clone your Ruby application repository that uses the Typesense client. If you need a reference setup, clone the official Typesense server repo for Docker Compose examples, but the server itself is not Ruby.

### Install Dependencies

On the VPS, install Docker. Pull the Typesense image:

```bash
docker pull typesense/typesense:30.2
```

For the Ruby app, run `bundle install` to install the `typesense` gem and any other gems.

### Configure Environment Variables

Set `TYPESENSE_API_KEY` to a long random string. Set `TYPESENSE_DATA_DIR` to `/data` on the host. Set `TYPESENSE_ENABLE_CORS` to `true` if your Ruby app is browser-based. Pass these to the Docker container via `-e` flags or a `.env` file.

### Start the Typesense Ruby Application

Start the Typesense server:

```bash
docker run -d -p 8108:8108 -v /data:/data -e TYPESENSE_API_KEY=your_key -e TYPESENSE_ENABLE_CORS=true typesense/typesense:30.2 --data-dir /data --api-key=your_key --enable-cors
```

Then start your Ruby application with `bundle exec rails server` or `ruby app.rb`. Point the client to `http://VPS_IP:8108`.

## Official Pricing of Typesense Ruby (Typesense Ruby pricing)

Typesense server is open-source under GPL-3.0. Self-hosting costs only infrastructure. Typesense Cloud starts at $21.60/mo for a 0.5GB burst cluster. The Ruby client library is open-source and free. No per-seat or per-query fees for self-hosted deployments. Cloud pricing scales with memory and replication. Railway self-hosting typically lands in single-digit to low-teens USD per month.

## Typesense Ruby cloud vs self hosted comparison (Pricing, features, costs, and more)

| Factor | Typesense Cloud | Self-hosted on Railway/VPS |
|--------|-----------------|----------------------------|
| Monthly cost | $21.60+ (0.5GB burst) | $5–15 on Railway, or VPS cost |
| Setup time | Minutes, no server management | 10–20 minutes via Docker |
| Scaling | Automatic, managed | Manual vertical scaling or add replicas |
| Data residency | Cloud provider regions | Your chosen VPS region |
| Backups | Managed snapshots | Manual volume snapshots or scripts |
| CORS, API key | Enabled via dashboard | Pass `--enable-cors` and `TYPESENSE_API_KEY` |
| License | GPL-3.0 server, proprietary dashboard | GPL-3.0 server, full control |

### Monthly cost of self hosting Typesense Ruby on Railway

Railway’s $5 GitHub trial credit covers the first month for most small Typesense deployments. After that, a typical single-container Typesense service with 512MB RAM and 0.5 vCPU costs $5–12/mo. Add a small Postgres for app data and the total stays under $15/mo. Larger datasets requiring 2GB+ RAM push cost to $15–25/mo. Railway bills per resource-minute, so idle development environments cost near zero.

### System Requirements for Hosting Typesense Ruby on a VPS

Minimum: 1 vCPU, 1GB RAM, 10GB SSD. This handles up to ~100k documents with light search traffic. Recommended for production: 2 vCPU, 4GB RAM, 20GB SSD for up to 1M documents and concurrent queries. Typesense stores data in `/data`—mount a persistent volume. Enable swap if RAM is tight. The server is single-binary and uses ~50MB idle memory.

## Frequently Asked Questions (FAQs)

Concrete answers for operators running Typesense Ruby on Railway.

### What port does Typesense use?

Default port `8108` for HTTP and `8109` for HTTPS. The Docker image exposes `8108`. Set `TYPESENSE_PORT` in the Ruby client to match.

### How do I enable CORS for Typesense Ruby?

Pass `--enable-cors` to the Typesense server binary or set `TYPESENSE_ENABLE_CORS=true` in Docker env. Without this, browser-based Ruby apps (e.g., Rails with Hotwire) get cross-origin errors.

### What license is Typesense Ruby under?

The Typesense server is GPL-3.0. The `typesense` Ruby gem is open-source, typically MIT. Self-hosting the server under GPL-3.0 requires you to release modifications if you distribute the binary.

### How much does Typesense Cloud cost vs Railway self-host?

Typesense Cloud’s smallest tier costs $21.60/mo for 0.5GB burst RAM. Railway self-host with 512MB–1GB RAM costs $5–15/mo after the $5 GitHub trial credit. Cloud includes managed backups and scaling; Railway requires you to handle those manually.

### Can I use Typesense Ruby with Rails?

Yes. Add `gem 'typesense'` to your Gemfile. Create an initializer that sets `Typesense::Client` as a global. Use ActiveJob to index records after commit. No special Rails middleware needed—just HTTP calls from the server.

### Does Typesense Ruby support vector search?

Yes. Typesense 30.2 supports built-in vector search via `embedding` fields.


## Similar templates

- [Typesense vs Meilisearch](https://railway.com/deploy/typesense-vs-meilisearch) — self-hosted Typesense vs Meilisearch
- [Betterlytics](https://railway.com/deploy/betterlytics) — Betterlytics is a cookieless analytics platform GDPR-compliant.
- [Finance Tracker](https://railway.com/deploy/finance-tracker-1) — Private multi-user household finance ledger with budgets and CSV import.

Open this page in a browser: https://railway.com/deploy/typesense-ruby
