Skip to main content
Self-hosted Sourcegraph runs entirely within your own infrastructure. Your source code, user data, and search indexes never leave your network. You are responsible for deployment, upgrades, backups, and monitoring — Sourcegraph provides the software, documentation, and support.

Self-hosted vs Cloud

Self-hosted

Your infrastructure. Your data stays on-premises or in your own cloud account. Full control over networking, storage, and upgrade timing. Requires a team capable of running containerized workloads.

Sourcegraph Cloud

Sourcegraph manages the infrastructure as a single-tenant instance. Automatic upgrades, monitoring, and backups. Requires your code hosts to be reachable from the Sourcegraph-managed environment.
Choose self-hosted when:
  • Your organization’s security policy prohibits code from leaving your network.
  • You need to connect to code hosts on a private network that is not accessible from the internet.
  • You require control over upgrade scheduling and data residency.
  • You have an existing Kubernetes or Docker infrastructure and the operational expertise to manage it.
Choose Sourcegraph Cloud when:
  • You want to get started quickly without managing infrastructure.
  • You prefer Sourcegraph to handle upgrades, backups, and monitoring.
  • Your code hosts are publicly accessible or reachable from Sourcegraph’s network.

Data residency

In a self-hosted deployment, the following data stays within your infrastructure:
  • Source code (cloned from your code hosts to Sourcegraph’s gitserver)
  • Search indexes (stored on persistent volumes attached to your cluster)
  • User data, settings, and audit logs (stored in PostgreSQL databases)
  • Batch Changes credentials and changeset data
  • Precise code intelligence (SCIP/LSIF) uploads
No source code is sent to Sourcegraph unless you are using Cody with a cloud-based LLM provider, and only then for the specific context windows included in AI requests.

Deployment types

Sourcegraph supports three primary deployment methods for self-hosted installations:

Docker Compose

Single-node deployment using Docker Compose. Best for small to medium teams (up to a few thousand users). Simpler to operate than Kubernetes but less scalable. Runs all Sourcegraph services as Docker containers on one host.

Kubernetes (Helm)

Multi-node deployment using Helm charts on Kubernetes. Recommended for large enterprises. Supports horizontal scaling, high availability, and integrates with managed Kubernetes services (GKE, EKS, AKS).
Machine image deployments (AWS AMI, Google Compute Image) are available but will be sunset in Sourcegraph 7.0.0. If you are considering machine images, contact your account team to discuss Docker Compose or Kubernetes instead.

System requirements

Resource requirements depend on the number of users and repositories you are indexing. Use the resource estimator to calculate requirements for your scale.
SizeUsersRepositoriesvCPUMemory
XSUp to 500Up to 5,000832 GB
SUp to 1,000Up to 10,0001664 GB
MUp to 5,000Up to 50,00032128 GB
LUp to 10,000Up to 100,00048192 GB
XLUp to 20,000Up to 250,00096384 GB
All deployments require SSD storage. If you fall between two size categories, choose the larger one. Additional requirements:
  • Docker Compose: Docker v20.10.0 or later, Docker Compose v1.29.0 or later. Docker Swarm mode is not supported.
  • Kubernetes/Helm: Kubernetes 1.19 or later, Helm 3 CLI, a CSI storage driver for persistent volumes, and an Ingress Controller.
  • ARM / ARM64 architectures are not supported for production deployments.

External services

For production deployments, Sourcegraph can be configured to use external managed services instead of the bundled ones:
  • PostgreSQL: Use your own PostgreSQL server (version 12 or later). Three databases are required: the main application database, the code intelligence database, and the code insights database.
  • Redis: Use external Redis instances for the cache and store services.
  • Object storage: Use S3-compatible storage or Google Cloud Storage for precise code intelligence (SCIP/LSIF) uploads.
Using external managed services is recommended for production — it separates data persistence from the Sourcegraph application lifecycle, simplifies backups, and allows independent scaling.

Licensing

A Sourcegraph Enterprise license is required for instances with more than 10 users. The license key is applied in site configuration:
{
  "licenseKey": "your-enterprise-license-key"
}
Contact [email protected] to obtain a license.

Next steps

Deployment guide

Step-by-step instructions for deploying Sourcegraph with Docker Compose or Kubernetes/Helm, including upgrade procedures.

Site configuration

Configure code host connections, authentication, search settings, and more after your instance is running.

Build docs developers (and LLMs) love