---
title: "Deploy OpenCode LSP"
description: "Language servers that feed diagnostics to OpenCode"
category: "AI/ML"
url: https://railway.com/deploy/deploy-opencode-with-lsp-servers
---

# Deploy OpenCode LSP

Language servers that feed diagnostics to OpenCode

**[Deploy OpenCode LSP on Railway](https://railway.com/template/deploy-opencode-with-lsp-servers)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-opencode-with-lsp-servers/manifest.json

- **Creator:** onepush
- **Category:** AI/ML

## Template content

### opencode

- **Image:** ghcr.io/onepush-dev/opencode:1.19.3@sha256:9a248429018cfcec9e51416ae5e85c78c45bb6c4b9e61141d7f18e435bedd6a3
- **Health check:** /site.webmanifest
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted OpenCode LSP (Language Server Setup for Coding Agents) on Railway

This template runs a self-hosted OpenCode server with language servers set up for diagnostics.

## About Hosting OpenCode LSP open-source software on Railway (self hosted OpenCode LSP server configuration on a self-hosted Railway box template)

This template runs one opencode service from the official image, with a volume at /data.

Railway handles the container, public domain, HTTPS, and restarts.

## Why Deploy OpenCode LSP, the Claude Code alternative on Railway (Railway Free Trial)

Claude Code is proprietary and tied to Anthropic models, so you can't change how it wires in language servers.

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 OpenCode LSP 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 OpenCode LSP self hosting

Railway trades some control for a managed deploy, so here is how each option compares.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | A one click template with a persistent /data volume and a generated password. | A bare Droplet where you install toolchains and set up HTTPS yourself. |
| AWS | Container, volume and domain wired together with no VPC setup first. | Full control of instances and networking, but you manage the volume and proxy. |
| Hetzner | A managed container with the volume and domain attached. | Low cost servers, but you run patches, firewall and TLS yourself. |

Toolchains you install inside the opencode container are the ones your LSP servers will find.

## Common Use Cases for hosted OpenCode LSP

- **Polyglot repo:** You work across TypeScript, Python and Go in one project under /data/workspace. Built-in servers start when you open a matching file, provided the toolchain for that language is installed in the container.
- **Silencing a heavy server:** One built-in server can slow agent runs on a large monorepo. Add "typescript": { "disabled": true } under the lsp key and the rest keep working.
- **In-house DSL:** Add a custom entry with a command array and an extensions list, and OpenCode starts it when it sees those file types.
- **Debugging a server:** Pass env variables through its entry, such as RUST_LOG set to debug on rust-analyzer, to see why diagnostics go missing.
- **Keeping config across redeploys:** Keep opencode.json at /data/home/.config/opencode/opencode.json. It sits on the volume, so your LSP settings survive every redeploy.

## Dependencies for OpenCode LSP Docker hosted on Railway

This template runs one opencode service from the official image, and the language servers it talks to are not in that image by default.

### Deployment Dependencies for Managed OpenCode LSP Service (AI Coding Agent)

- **Image:** ghcr.io/onepush-dev/opencode:1.19.3, on port 4096 with a public Railway domain.
- **Volume:** one volume at /data, holding /data/workspace, /data/home and the config under /data/home/.config/opencode.
- **Required variable:** OPENCODE_SERVER_PASSWORD, which the entrypoint needs before it starts.
- **Toolchains:** installed by you inside the container, such as the go command for gopls or the .NET SDK for csharp.

### Implementation Details for OpenCode LSP (Using OpenCode official docker image)

The entrypoint runs opencode serve --hostname 0.0.0.0 --port 4096 with tini as PID 1.

## How does OpenCode LSP compare against other ways to configure language servers for terminal coding agents

OpenCode's built-in language servers start on their own when you open a matching file, so the comparison focuses on how each tool handles LSP config.

### OpenCode LSP vs Claude Code (Anthropic Terminal Agent Alternative)

- **Config surface:** OpenCode exposes an lsp key in opencode.json where you can enable everything with "lsp": true, keep built-ins with "lsp": {}, or add a custom server. Claude Code is tied to Anthropic models and lacks this kind of file-level LSP tuning.
- **Where Claude Code wins:** It is more polished with less setup, so if you only use Claude models, it is the simpler path.
- **Hosting:** On this template the config persists under /data/home/.config/opencode, but you still install toolchains yourself.

### OpenCode LSP vs Cursor (Proprietary VS Code Fork Alternative)

- **Where it runs:** Cursor runs its language servers on your laptop, while OpenCode LSP runs them on the Railway box next to /data/workspace.
- **Where Cursor wins:** Its inline completions and mature UI suit anyone who wants the agent inside an IDE.
- **Trade-off:** Remote servers mean you manage toolchain installs in the container.

### OpenCode LSP vs Aider (Open-Source Terminal Pair Programmer Alternative)

- **License:** Aider is Apache-2.0 and git-native, and OpenCode is MIT licensed, so both suit a self-hosted setup.
- **Where Aider wins:** It needs no server to run, so there is less to operate.
- **Where OpenCode fits:** Its lsp key gives per-server control over disabled, command, extensions, env and initialization.

### OpenCode LSP vs Cline (Open-Source VS Code Agent Alternative)

- **Surface:** Cline runs inside VS Code and uses the language servers your editor provides, while OpenCode is a server you reach over the network.
- **Where Cline wins:** If you already live in VS Code, it is the simpler route with no server to run.
- **Config:** On OpenCode you can turn one server off with "lsp": { "typescript": { "disabled": true } }.

## How to use OpenCode LSP (the OSS AI coding agent)?

1. Open a shell in the opencode service and check that HOME is /data/home.
2. Create or edit /data/home/.config/opencode/opencode.json and add an lsp key. Use `"lsp": {}` to keep the built-in servers on, or disable one with `"typescript": { "disabled": true }`. Add a custom entry with command and extensions if you need one.
3. Install the required toolchain inside the opencode service container. gopls needs the go command, and rust needs rust-analyzer on the command path.
4. Put your project under /data/workspace, which OPENCODE_WORKSPACE points at.
5. Set OPENCODE_DISABLE_LSP_DOWNLOAD to true if you want to stop automatic server downloads.
6. Open a file with a matching extension and confirm the server starts. If it doesn't, check the toolchain from step 3 first.

```json
{
  "lsp": {
    "typescript": {
      "disabled": true
    },
    "custom-lsp": {
      "command": ["custom-lsp-server", "--stdio"],
      "extensions": [".custom"]
    }
  }
}
```

## How to self host OpenCode LSP on other VPS Services (OpenCode self hosting guide)

Running OpenCode LSP on a plain VPS works the same way, but you own every piece.

### Clone the Repository

Pull the template repo onto the server and move into it.

```bash
git clone https://github.com/your-domain/opencode-lsp.git
cd opencode-lsp
```

### Install Dependencies

Install OpenCode and the toolchains your built-in servers need. gopls will not start unless the go command is on the path, and rust needs rust-analyzer installed on the VPS itself.

```bash
npm i -g opencode-ai
go version
rust-analyzer --version
```

### Configure Environment Variables

Set a strong server password and the config home before you start. Put user-level LSP settings in opencode.json under that home.

```bash
export OPENCODE_SERVER_PASSWORD="$(openssl rand -hex 16)"
export HOME=/srv/opencode/home
export OPENCODE_DISABLE_LSP_DOWNLOAD=true
```

### Start the OpenCode LSP Application

Run the server bound to all interfaces on port 4096, then put it behind HTTPS with a reverse proxy.

## Official Pricing of OpenCode LSP (OpenCode pricing)

OpenCode itself is free and open source under the MIT license, so there is no license fee for running the server or the language servers it starts.

## OpenCode LSP cloud vs self hosted comparison (Pricing, features, costs, and more)

Self hosting OpenCode LSP on Railway swaps a hosted subscription for a container you control, and the real differences are compute cost and how much language server setup you own.

### Monthly cost of self hosting OpenCode LSP on Railway

OpenCode is free and open source, so your bill is the Railway container plus any model API calls.

### System Requirements for Hosting OpenCode LSP on a VPS

On a VPS, budget enough RAM for the agent plus each language server you enable, since servers stay resident once started.

## Frequently Asked Questions (FAQs)

### How do built-in LSP servers start in OpenCode?

OpenCode ships built-in language servers that start automatically when you open a file with a matching extension and the server's requirements are met.

### What is the difference between "lsp": true, "lsp": {} and "lsp": false?

Setting "lsp": true enables every built-in server. Setting "lsp": false turns all servers off, even if another config enabled them.

### How do I disable one built-in server like typescript?

Add "lsp": { "typescript": { "disabled": true } } to /data/home/.config/opencode/opencode.json. The other built-in servers stay active.

### How do I add a custom language server with command and extensions?

Add an entry with a command array and an extensions list, such as "custom-lsp": { "command": ["custom-lsp-server", "--stdio"], "extensions": [".custom"] }.

### Where does the LSP config persist on this Railway template?

User-level config lives at /data/home/.config/opencode/opencode.json, since HOME is /data/home on this template.

### Why does a server need its toolchain installed in the container?

Many servers wrap a language runtime, so gopls needs the go command and rust-analyzer needs to be on the command path.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/deploy-opencode-with-lsp-servers
