This guide was written in 2019 for Sentry 9.1. Sentry’s self-hosted setup has changed since then, so check the official documentation before following these steps. The getsentry/onpremise repository used below has since been renamed getsentry/self-hosted.
Sentry’s cross-platform application monitoring helps teams analyse errors and bugs in live applications. We use Sentry internally to track errors, which makes it easy to analyse and fix problems quickly across an application. This tutorial sets up Sentry on a plain Ubuntu machine. Sentry also publishes official documentation for installing with Docker.

1. Add swap memory
This tutorial uses a 1 GB machine, but at least 4 GB is recommended to avoid memory problems during installation. SSH in to your machine.
We add 4 GB of swap, since 1 GB of RAM can cause memory issues during installation. First check whether swap is already configured; you can skip this step if your machine has at least 4 GB of memory.
sudo swapon --show
free -hCreate a 4 GB swap file, check it, set its permissions, mark it as swap and enable it:
sudo fallocate -l 4G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h2. Install Docker
Set up the Docker repository:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"Then install Docker CE:
sudo apt-get update
sudo apt-get install docker-ceVerify the installation:
sudo docker run hello-world3. Install Sentry on-premise
Clone the Sentry on-premise repository:
git clone https://github.com/getsentry/onpremise.gitChange into the folder, create the installer script and paste in the contents below. Edit the configuration section at the top before you begin. system.url-prefix is the URL where Sentry will be available, so configure that domain on your web server.
cd onpremise && sudo nano installer.sh#!/usr/bin/env bash
echo "Applying config.yml values"
cat <<EOT > config.yml
auth.allow-registration: false #prevents public registration
beacon.anonymous: true
mail.backend: 'smtp'
mail.from: "[email protected]"
mail.host: "smtp.yourdomain.com"
mail.password: "password"
mail.port: 465
mail.use-tls: true
mail.username: "[email protected]"
system.admin-email: "[email protected]"
system.url-prefix: "https://sentry.yourdomain.com"
EOT
echo "Building Sentry onpremise"
make build
docker container stop sentry-cron sentry-worker sentry-web sentry-postgres sentry-redis
docker container rm sentry-cron sentry-worker sentry-web sentry-postgres sentry-redis
docker run \
--detach \
--name sentry-redis \
redis:3.2-alpine
docker run \
--detach \
--name sentry-postgres \
--env POSTGRES_PASSWORD='sentry' \
--env POSTGRES_USER=sentry \
-v /opt/docker/sentry/postgres:/var/lib/postgresql/data \
postgres:latest
echo "Generating secret key"
docker run --rm sentry-onpremise config generate-secret-key > key
SENTRY_SECRET_KEY=$(cat key)
echo "Running migrations"
echo "This can take time based on memory usage"
docker run \
--rm \
-it \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
-v /opt/docker/sentry/sentry:/var/lib/sentry/files \
sentry-onpremise \
upgrade
echo "Installing plugins"
docker run \
--rm \
-it \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
-v /opt/docker/sentry/sentry:/var/lib/sentry/files \
sentry-onpremise \
pip install sentry-plugins
echo "Running service WEB"
docker run \
--detach \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-web \
--publish 9000:9000 \
-v /opt/docker/sentry/sentry:/var/lib/sentry/files \
sentry-onpremise \
run web
sleep 15
echo "Running service WORKER"
docker run \
--detach \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-worker \
-v /opt/docker/sentry/sentry:/var/lib/sentry/files \
sentry-onpremise \
run worker
sleep 15
echo "Running service CRON"
docker run \
--detach \
--link sentry-redis:redis \
--link sentry-postgres:postgres \
--env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} \
--name sentry-cron \
-v /opt/docker/sentry/sentry:/var/lib/sentry/files \
sentry-onpremise \
run cron
date
sleep 60
date
docker exec sentry-web sentry config set sentry:version-configured '9.1.0'This script is available online, and credit goes to its original author. It asks you to set up login credentials during the process, which can take some time depending on your server. If the process exits, your server does not have enough memory: increase the swap or move to a larger machine.
Once installed, open your_server_ip:9000 to finish the setup.
4. Set up Nginx
To serve Sentry on your own domain, install Nginx:
sudo apt-get update
sudo apt-get install nginx
sudo ufw allow 'Nginx HTTP'Visiting your server’s IP address now shows the Nginx welcome page. Add a configuration for your site:
cd /etc/nginx/sites-available
sudo cp default sentry.yourdomain.com
sudo nano sentry.yourdomain.comPaste in the following. This is a minimal setup, so add security measures as needed.
server {
listen 80;
server_name sentry.yourdomain.com;
location / {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable the server block and restart Nginx:
sudo ln -s /etc/nginx/sites-available/sentry.yourdomain.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx5. Add HTTPS with Let’s Encrypt
Finally, add HTTPS using Let’s Encrypt. Install certbot:
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginxThen generate a certificate:
sudo certbot --nginx -d sentry.yourdomain.comYou can now log in at sentry.yourdomain.com with the credentials you set up during installation. Sentry is running on your own server. You may also like our guide to importing CSV into Redis.