Deploy Eclipse Mosquitto
MQTT broker: login required, data on a volume, WebSocket and dashboard
Mosquitto
Just deployed
/mosquitto/data
Deploy and Host Eclipse Mosquitto on Railway
Eclipse Mosquitto is a small, open-source MQTT broker from the Eclipse Foundation. Devices, apps and services publish messages to topics, and the broker delivers them to every subscriber. It supports MQTT 5.0, 3.1.1 and 3.1, QoS 0–2, retained messages and persistent sessions, and since 2.1 it ships a built-in web dashboard.
About Hosting Eclipse Mosquitto
This template runs Mosquitto 2.1.2 from the official image, pinned by digest, as one service built from a public GitHub repo. Every client has to log in: the username is mqtt and the password is generated at deploy. Plain MQTT is reachable through a Railway TCP proxy, and from other services over the private network on port 1883. The service's HTTPS domain carries MQTT over WebSocket at /mqtt and the Mosquitto dashboard at /, behind the same login. Retained messages, persistent sessions and queued messages are saved to a volume, so they survive restarts and redeploys. After deploy, copy MQTT_URL or MQTT_PUBLIC_URL from the service's variables.
Common Use Cases
- Collect sensor data from ESP32, Arduino or Raspberry Pi devices, or from Home Assistant, Node-RED and Zigbee2MQTT
- Pass events between backend services and workers in the same Railway project
- Push live updates to browsers and mobile apps over MQTT on WebSocket
Dependencies for Eclipse Mosquitto Hosting
- The official
eclipse-mosquittoDocker image (2.1.2, Alpine) - A Railway volume for the persistence file, a TCP proxy for MQTT and a Railway domain for WebSocket and the dashboard
Deployment Dependencies
- Mosquitto website and documentation
- Mosquitto 2.1.2 release and changelog
- Official Docker image
- Template repo: aalfath/mosquitto-railway-template
Implementation Details
| Where | Address |
|---|---|
| Other Railway services | ${{Mosquitto.MQTT_URL}} (mqtt://mqtt:PASSWORD@mosquitto.railway.internal:1883) |
| Outside Railway, plain MQTT | ${{Mosquitto.MQTT_PUBLIC_URL}} (TCP proxy host and port; unencrypted) |
| Outside Railway, encrypted | wss://YOUR-DOMAIN/mqtt on port 443 |
| Dashboard | https://YOUR-DOMAIN/, log in with mqtt and MQTT_PASSWORD |
Anonymous logins are refused on every listener. To add more users, set MQTT_EXTRA_USERS on the service as user1:password1,user2:password2 and redeploy; to change the password, change MQTT_PASSWORD and redeploy. The health check is /healthz. Updates: when the repo moves to a new Mosquitto version, Railway shows an "update available" notice on your project; read the repo's CHANGELOG.md, then apply it.
Why Deploy Eclipse Mosquitto 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 Eclipse Mosquitto 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.
Template Content
Mosquitto
aalfath/mosquitto-railway-template