---
title: "Deploy Telegram MTProxy | Survives a Cold Start, Prints a Link That Works"
description: "Telegram MTProxy on Railway: retries on boot, link matches the real host"
category: "Other"
url: https://railway.com/deploy/telegram-mtproxy-or-survives-a-cold-star
---

# Deploy Telegram MTProxy | Survives a Cold Start, Prints a Link That Works

Telegram MTProxy on Railway: retries on boot, link matches the real host

**[Deploy Telegram MTProxy | Survives a Cold Start, Prints a Link That Works on Railway](https://railway.com/template/telegram-mtproxy-or-survives-a-cold-star)**

- **Creator:** Pavel Volkov's Projects
- **Category:** Other

## Template content

### MTProxy

- **Source:** https://github.com/ak40u/mtproxy-railway-starter

## Documentation

# Deploy and Host Telegram MTProxy on Railway

MTProxy is Telegram's own proxy, speaking the MTProto protocol its clients already
use. It relays traffic between a client and Telegram's servers without decrypting
or inspecting it, which makes it a common way to keep Telegram reachable on
networks that throttle or block it.

## About Hosting Telegram MTProxy

The proxy is a single small C daemon. Hosting it means three things have to line
up. It needs Telegram's current server list, which it downloads at every start, so
a cold start on a busy network can fail if that request is given only one attempt.
It needs to know its own external address for the NAT hint it sends to Telegram.
And, most easily missed, the address it advertises to clients has to be the address
clients can actually reach: on Railway a container is not reachable at its own IP,
traffic arrives through a TCP proxy on a port Railway assigns. A proxy whose link
points anywhere else is running perfectly and serving nobody.

## Common Use Cases

- Keeping Telegram usable on a network where it is throttled or blocked
- Running a proxy for a group, a community or a family, on a host you control
- Registering the proxy with [@MTProxybot](https://t.me/MTProxybot) to show a sponsored channel to its users

## Dependencies for Telegram MTProxy Hosting

- A TCP proxy on port 443, which this template configures
- A volume on `/data`, which keeps the secret stable across redeploys

### Deployment Dependencies

- [MTProxy source](https://github.com/TelegramMessenger/MTProxy) and the official `telegrammessenger/proxy` image
- [This template's repository](https://github.com/ak40u/mtproxy-railway-starter)
- [@MTProxybot](https://t.me/MTProxybot) if you want a proxy tag

### Implementation Details

The MTProxy template in the catalog sits at 44% health across 2893 deployments.
Both causes are in `/run.sh` inside the official image, and both are fixed here:

- **A single third-party host decides whether the deploy lives.** Upstream reads
  the external IP from `https://digitalresistance.dog/myIp` and exits with code 3
  when that answer is empty - no retry, no second source. Here four sources are
  tried, and a failure is no longer fatal: it only skips the NAT hint.
- **The link points at the wrong address.** Upstream prints
  `tg://proxy?server=&amp;port=443`, which nothing can connect to on
  Railway. Here the links are built from `RAILWAY_TCP_PROXY_DOMAIN` and
  `RAILWAY_TCP_PROXY_PORT`, the address the platform actually publishes.

Telegram's server list is also fetched with five attempts instead of one. The
proxy binary and its arguments are unchanged from upstream.

After the deploy, the logs print the link in three forms: `tg://` to open a client
directly, `https://t.me/proxy?...` to share, and one with a `dd`-prefixed secret,
which asks clients to pad packets and helps where plain MTProto is filtered.

## Why Deploy Telegram MTProxy 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 Telegram MTProxy 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/telegram-mtproxy-or-survives-a-cold-star
