# Deploy Mosquitto with Easypanel

URL: /templates/mosquitto

Eclipse Mosquitto is a lightweight open-source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. It is used to connect IoT devices, sensors, home automation systems and backend services through a simple publish and subscribe model, and is small enough to run on anything from a Raspberry Pi to a large server. This template runs Mosquitto with password authentication, persistent message storage, a plain MQTT port and MQTT over secure WebSockets on the app domain.

## Installation notes

The username is set in the template form and the password is generated on deploy. Both are in the MOSQUITTO_USERNAME and MOSQUITTO_PASSWORD environment variables of the service, and changing them takes effect on the next deploy. Browsers, dashboards and devices that support it can connect over secure WebSockets at wss://your-domain on port 443. Plain MQTT is not published by default because it sends the password unencrypted. Turn on Publish Plain MQTT Port only for devices that can't use WebSockets, ideally on a private network, and make sure that port is open in the server firewall.

## Benefits

### Lightweight And Fast

Mosquitto uses very little memory and CPU, so it can handle thousands of clients on a small server.

### Standard MQTT Broker

Works with any MQTT client, library or device, including Home Assistant, Node-RED, Zigbee2MQTT, ESP32 and Tasmota.

### Secure By Default

Anonymous access is disabled and clients must sign in with a username and a generated password.

### Full Data Ownership

Messages, retained topics and sessions stay on your own server instead of a hosted broker.

## Features

### MQTT 5.0, 3.1.1 And 3.1

Supports every current MQTT version, including MQTT 5 features such as shared subscriptions, message expiry and user properties.

### Publish And Subscribe

Clients publish to topics and subscribe with wildcards, with QoS 0, 1 and 2 delivery guarantees.

### Retained Messages And Sessions

Retained messages, queued messages and persistent sessions are written to a SQLite database within seconds, so they survive restarts, redeploys and crashes.

### MQTT Over WebSockets

Browsers and web dashboards can connect over secure WebSockets on the app domain with HTTPS handled by Easypanel.

### Plain MQTT Port

Devices and services connect directly on the published MQTT port of the server.

### Password Authentication

Clients authenticate with a username and password that are stored as a hashed password file.

## Configuration

- `appServiceName` (App Service Name, required): mosquitto

- `appServiceImage` (App Service Image, required): eclipse-mosquitto:2.1.2-alpine

- `username` (MQTT Username, required): mosquitto

- `publishMqttPort` (Publish Plain MQTT Port): false — Unencrypted MQTT for devices that can't use WebSockets.

- `mqttPort` (MQTT Port on Host): 1883

## Services

- mosquitto: app (eclipse-mosquitto:2.1.2-alpine)

## Resources

- [Website](https://mosquitto.org)

- [Documentation](https://mosquitto.org/documentation/)

- [Github](https://github.com/eclipse-mosquitto/mosquitto)

- [Template source](https://github.com/easypanel-io/templates/tree/main/templates/mosquitto)