---
title: "Deploy Nakama"
description: "Nakama 3.41 game server with Postgres, client API and admin console."
category: "Other"
url: https://railway.com/deploy/nakama-1
---

# Deploy Nakama

Nakama 3.41 game server with Postgres, client API and admin console.

**[Deploy Nakama on Railway](https://railway.com/template/nakama-1)**

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

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

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### nakama https://github.com/heroiclabs.png

- **Image:** heroiclabs/nakama:3.41.0
- **Start command:** `sh -c '/nakama/nakama migrate up --database.address "$NAKAMA_DATABASE_ADDRESS" && exec /nakama/nakama --name nakama1 --database.address "$NAKAMA_DATABASE_ADDRESS" --logger.level INFO --socket.server_key "$NAKAMA_SERVER_KEY" --session.encryption_key "$NAKAMA_SESSION_ENCRYPTION_KEY" --session.refresh_encryption_key "$NAKAMA_SESSION_REFRESH_KEY" --runtime.http_key "$NAKAMA_RUNTIME_HTTP_KEY" --console.username "$NAKAMA_CONSOLE_USERNAME" --console.password "$NAKAMA_CONSOLE_PASSWORD" --console.signing_key "$NAKAMA_CONSOLE_SIGNING_KEY"'`
- **Health check:** /healthcheck
- **Public domain:** Yes

## Documentation

# Deploy and Host Nakama on Railway

Nakama is an open-source game server for multiplayer and social features. It provides user accounts and device authentication, realtime multiplayer, matchmaking, chat, leaderboards, tournaments, storage and in-app purchase validation, with client SDKs for Unity, Unreal, Godot, Defold, JavaScript, Swift and Kotlin. The server is written in Go.

## About Hosting Nakama

This template deploys Nakama 3.41.0 with a Railway Postgres database. Migrations run before every start. The service has two public domains: the client API and realtime socket on port 7350, and the admin console on 7351. The server key, session keys, runtime HTTP key, console password and console signing key are all generated at deploy time, replacing Nakama's well-known development defaults. Custom Lua, TypeScript or Go modules need your own image built from the official one. The Hobby plan fits development and small games. Back up Postgres regularly, since it holds all player data.

## Common Use Cases

- Accounts, friends, chat and leaderboards for mobile and web games
- Realtime multiplayer and matchmaking backends
- A self-hosted alternative to hosted game backend services

## Dependencies for Nakama Hosting

- `heroiclabs/nakama:3.41.0` (official image)
- Railway Postgres (`ghcr.io/railwayapp-templates/postgres-ssl:18`) with a volume

### Deployment Dependencies

- [Nakama documentation](https://heroiclabs.com/docs/nakama/)
- [Nakama v3.41.0 release](https://github.com/heroiclabs/nakama/releases/tag/v3.41.0)
- [Nakama client libraries](https://heroiclabs.com/docs/nakama/client-libraries/)
- [Railway private networking](https://docs.railway.com/reference/private-networking)

### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| nakama | `heroiclabs/nakama:3.41.0` | public API domain (7350) and console domain (7351) | none (state in Postgres) |
| Postgres | Railway Postgres 18 | private only | volume |

Client SDKs use the API domain on port 443 with SSL and the generated server key:

```js
const client = new Client(process.env.NAKAMA_SERVER_KEY, "", "443", true);
const session = await client.authenticateDevice(deviceId, true);
```

| Variable | Default | Purpose |
| --- | --- | --- |
| `NAKAMA_SERVER_KEY` | generated | Key clients use to authenticate |
| `NAKAMA_CONSOLE_USERNAME` / `_PASSWORD` | `admin` / generated | Admin console login |
| `NAKAMA_SESSION_ENCRYPTION_KEY` / `_REFRESH_KEY` | generated | Session token signing |
| `NAKAMA_RUNTIME_HTTP_KEY` | generated | Key for server-to-server RPC calls |

Notes:

- Configuration is passed as flags in the start command; add more `--flag value` pairs there.
- The gRPC API (7349) is not exposed; clients use HTTP and WebSocket on 7350.

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

## Why Deploy Nakama 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 Nakama 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

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/nakama-1
