---
title: "Deploy Grafana Loki"
description: "Grafana Loki 3.7 log aggregation with volume storage and auth gateway."
category: "Observability"
url: https://railway.com/deploy/grafana-loki
---

# Deploy Grafana Loki

Grafana Loki 3.7 log aggregation with volume storage and auth gateway.

**[Deploy Grafana Loki on Railway](https://railway.com/template/grafana-loki)**

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

- **Creator:** Agaz Self-Host
- **Category:** Observability

## Template content

### gateway https://raw.githubusercontent.com/caddyserver/website/5c921006aae4feb2184782ae528c2bb09a07e04f/src/resources/images/favicon.png

- **Image:** caddy:2.11.4-alpine
- **Start command:** `sh -c 'export LOKI_QUERY_PASSWORD_HASH="$(caddy hash-password --plaintext "$LOKI_QUERY_PASSWORD")" LOKI_PUSH_PASSWORD_HASH="$(caddy hash-password --plaintext "$LOKI_PUSH_PASSWORD")" && printf "%s\n" "$CADDYFILE" > /tmp/Caddyfile && exec caddy run --config /tmp/Caddyfile --adapter caddyfile'`
- **Health check:** /healthz
- **Public domain:** Yes

### loki https://raw.githubusercontent.com/grafana/loki/v3.7.8/docs/sources/logo.png

- **Image:** grafana/loki:3.7.8
- **Start command:** `/usr/bin/loki -config.file=/etc/loki/local-config.yaml -compactor.retention-enabled=true -compactor.delete-request-store=filesystem -store.retention=14d -reporting.enabled=false`
- **Health check:** /ready

## Documentation

# Deploy and Host Grafana Loki on Railway

Grafana Loki is a horizontally scalable, cost-efficient log aggregation system inspired by Prometheus. It indexes only labels, not full text, and stores compressed log chunks, so it is cheap to run. Logs are pushed by Grafana Alloy, Promtail, Fluent Bit, Vector or OpenTelemetry and queried with LogQL in Grafana.

## About Hosting Grafana Loki

This template deploys Loki v3.7.8 in single-binary mode with filesystem storage on a Railway volume, plus a Caddy gateway that is the only public entry point. The gateway has two logins: `push` for shipping logs and `admin` for queries from Grafana; each works only on its own routes. Logs are kept for 14 days by the compactor, and usage reporting is off. Loki itself stays private and runs as root so it can write to the volume. Watch the volume size on the Hobby plan, since storage grows with log volume.

## Common Use Cases

- Centralized logs for apps and services running on Railway and elsewhere
- LogQL queries and alerts in Grafana next to metrics and traces
- A low-cost self-hosted alternative to hosted log platforms

## Dependencies for Grafana Loki Hosting

- `grafana/loki:3.7.8` (official image) with a volume at `/loki`
- `caddy:2.11.4-alpine` (official image) as the authenticated gateway

### Deployment Dependencies

- [Loki documentation](https://grafana.com/docs/loki/latest/)
- [Loki v3.7.8 release](https://github.com/grafana/loki/releases/tag/v3.7.8)
- [Sending logs to Loki](https://grafana.com/docs/loki/latest/send-data/)
- [Railway volumes](https://docs.railway.com/reference/volumes)

### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| loki | `grafana/loki:3.7.8` | private only, port 3100 | volume at `/loki` |
| gateway | `caddy:2.11.4-alpine` | public domain on 8080 | none |

Push (Alloy / Promtail / Fluent Bit) to `https:///loki/api/v1/push` with basic auth `push:`; OTLP logs go to `/otlp/v1/logs`. In Grafana, add a Loki data source with URL `https://` and basic auth `admin:`, or `${{loki.LOKI_PRIVATE_URL}}` from inside the project.

| Variable | Service | Default | Purpose |
| --- | --- | --- | --- |
| `LOKI_PUSH_USERNAME` / `_PASSWORD` | gateway | `push` / generated | Log shipping credentials |
| `LOKI_QUERY_USERNAME` / `_PASSWORD` | gateway | `admin` / generated | Query credentials |
| `CADDYFILE` | gateway | gateway config | Routing and auth |

Notes:

- Retention (`-store.retention=14d`) and compaction are set in the Loki start command; change the value there.
- Loki has no authentication of its own, which is why it stays private behind the gateway.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the Grafana Loki project or its maintainers.

## Why Deploy Grafana Loki on Railway?

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 Grafana Loki 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.


## Similar templates

- [Rootprint](https://railway.com/deploy/rootprint-1) — Open-source logs and traces with full-text search on object-storage.
- [Pyroscope profiling](https://railway.com/deploy/pyroscope-profiling) — Protected continuous profiling with durable Pyroscope storage.
- [SigOnly](https://railway.com/deploy/sigonly) — Deploy SigNoz with a working demo app & config in one click

Open this page in a browser: https://railway.com/deploy/grafana-loki
