MOSQUITTO_CTRL(1)
πΈ MOSQUITTO_CTRL(1) β Commands πΈ
okay bestie, welcome to mosquitto_ctrl, from the Commands section of your manual. this one's a whole vibe β it's the tool you use to init and configure a Mosquitto broker instance, and honestly it's giving main character energy for your broker setup. π
β¨ NAME β¨
mosquitto_ctrl β a tool for initialising/configuring a Mosquitto broker instance
fr fr that's the whole job. it sets things up, it configures things, it's that girl. π
π¦ SYNOPSIS π¦
okay so here's the whole menu, and yes, every single variant is included because we do not skip details in this house:
mosquitto_ctrl [options | -o config-file] module-name module-command
[command-options]
options: [auth-options] [connection-options] [mqtt-options]
[output-options] [tls-certificate-options | tls-psk-options]
auth-options:
[-u username] [-P password]
connection-options:
{[-h hostname] [--unix socket path] [-p port-number]
| -L URL}
[-A bind-address]
[--proxy socks-url]
mqtt-options:
[-c] [-i client-id] [-q message-QoS] [-V protocol-version]
output-options:
[-d] [--quiet]
tls-certificate-options:
[--no-tls]
{--cafile file | --capath dir}
[--tls-use-os-certs]
[--cert file] [--key file]
[--ciphers ciphers] [--insecure]
[--tls-alpn protocol] [--tls-keylog file]
[--tls-version version]
[--tls-engine engine]
[--keyform {pem | engine}]
[--tls-engine-kpass-sha1 kpass-sha1]
tls-psk-options:
--psk hex-key --psk-identity identity
[--ciphers ciphers] [--tls-version version]
mosquitto_ctrl [connection-options] (interactive shell
mode)
mosquitto_ctrl [--help]
like, look at all those little bracket groups β they're nested and adorable and they all matter. π«Ά
π DESCRIPTION π
so mosquitto_ctrl is a tool for helping configure a Mosquitto broker instance. periodt. that's the mission.
you can run it primarily as a straightforward command line tool β literally exactly like the synopsis up there describes β or as an interactive shell, which is its own whole thing documented over in mosquitto_ctrl_shell(1). and ngl, the interactive shell makes most operations very straightforward and is recommended for ease of use. so if you're ever like "ugh, flags", bestie, go read that one too. β¨
π ENCRYPTED CONNECTIONS π
mosquitto_ctrl supports TLS encrypted connections, and it is strongly recommended that you use an encrypted connection for all remote use of mosquitto_ctrl. no cap, just do it. π₯
to enable TLS connections when using x509 certificates, one of either --cafile or --capath must be provided as an option. like, it's not optional-optional, it's required-required. π
to enable TLS connections when using TLS-PSK, you must use the --psk and the --psk-identity options. both of them. together. they're a package deal. π
π§ MODULES π§
π Dynamic security
authentication, and role based access control with users and groups. it uses the module name dynsec. see: mosquitto_ctrl_dynsec(1)
(that one's the icon, honestly. usernames, groups, roles β very cunty access control. π)
π External modules
mosquitto_ctrl has the ability to load external modules in the form of shared libraries. for example, using the module name example will try to load the external module mosquitto_ctrl_example.so or mosquitto_ctrl_example.dll, depending on platform. this allows new functionality to be added to Mosquitto by combining a plugin and a mosquitto_ctrl module, without having to recompile any Mosquitto source code. slay. π
(part 1 done β more coming, don't you dare close the tab π¦)
π CONNECTION OPTIONS π
okay so bestie, these options can be dropped right on the command line, but they can also live in a config file at $XDG_CONFIG_HOME/mosquitto_ctrl or $HOME/.config/mosquitto_ctrl.
You can also point at a config file manually with the -o config-file option.
The config file should have one pair of -option value per line. The values in the config file will be used as defaults and can be overridden by using the command line. The exceptions to this are the message type options, of which only one can be specified. Note also that currently some options cannot be negated, e.g. -S. Config file lines that have a # as the first character are treated as comments and not processed any further.
-Aβ Bind the outgoing connection to a local ip address/hostname. Use this argument if you need to restrict network communication to a particular interface.--cafileβ Define the path to a file containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. See also--capath.--capathβ Define the path to a directory containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. For--capathto work correctly, the certificate files must have".crt"as the file ending and you must runopenssl rehash <path to capath>each time you add/remove a certificate. See also--cafile.--certβ Define the path to a file containing a PEM encoded certificate for this client, if required by the server. See also--keyand the Encrypted Connections section.--ciphersβ An openssl compatible list of TLS ciphers to support in the client. Seeciphers(1)for more information.-d,--debugβ Enable debug messages.-D,--propertyβ Set MQTT v5 properties for this client. If you use this option, the client will be set to be an MQTT v5 client. This option has two forms:-D command identifier valueand-D command identifier name value.
command is the MQTT command/packet identifier and can be one of CONNECT, PUBLISH, PUBACK, PUBREC, PUBCOMP, SUBSCRIBE, UNSUBSCRIBE, DISCONNECT, AUTH, or WILL. The properties available for each command are listed in the Properties section.
identifier is the name of the property to add. This is as described in the specification, but with - as a word separator. For example: payload-format-indicator. More details are in the Properties section.
value is the value of the property to add, with a data type that is property specific.
name is only used for the user-property property as the first of the two strings in the string pair. In that case, value is the second of the strings in the pair.
--helpβ Display usage information.-h,--hostβ Specify the host to connect to. Defaults tolocalhost.-i,--idβ The id to use for this client. If not given, a client id will be generated depending on the MQTT version being used. For v3.1.1/v3.1, the client generates a client id in the formatmosq-XXXXXXXXXXXXXXXXXX, where the X are replaced with random alphanumeric characters. For v5.0, the client sends a zero length client id, and the server will generate a client id for the client.--insecureβ When using certificate based encryption, this option disables verification of the server hostname in the server certificate. This can be useful when testing initial server configurations but makes it possible for a malicious third party to impersonate your server through DNS spoofing, for example.
β οΈ Use this option in testing only. If you need to resort to using this option in a production environment, your setup is at fault and there is no point using encryption. π
--keyβ Define the path to a file containing a PEM encoded private key for this client, carrying out mutual TLS with the server. See also--certand the Encrypted Connections section.--keyformβ Specifies the type of private key in use when making TLS connections. This can bepemorengine. This parameter is useful when a TPM module is being used and the private key has been created with it. Defaults topem, which means normal private key files are used. See also--tls-engine.-L,--urlβ Specify user, password, hostname, port and topic at once as a URL. The URL must be in the form:
mqtt(s)://[username[:password]@]host[:port]/topic or
ws(s)://[username[:password]@]host[:port]/path
Depending on the scheme, the port will default to different values. mqtt:// - 1883, mqtts:// - 8883, ws:// - 80, wss:// - 443.
--nodelayβ Disable Nagle's algorithm for the socket. This means that latency of sent messages is reduced, which is particularly noticeable for small, reasonably infrequent messages. Using this option may result in more packets being sent than would normally be necessary.-o config-fileβ Provide a path to a config file to load options from. The config file should have one pair of-option valueper line. The values in the config file will be used as defaults and can be overridden by using the command line. The exceptions to this are the message type options, of which only one can be specified. Note also that currently some options cannot be negated, e.g.-S. Config file lines that have a#as the first character are treated as comments and not processed any further.-p,--portβ Connect to the port specified. If not given, the default of1883for plain MQTT or8883for MQTT over TLS will be used.-P,--pwβ Provide a password to be used for authenticating with the broker. Using this argument without also specifying a username is invalid when using MQTT v3.1 or v3.1.1. See also the--usernameoption.--proxyβ Specify a SOCKS5 proxy to connect through."None"and"username"authentication types are supported. Thesocks-urlmust be of the formsocks5h://[username[:password]@]host[:port]. The protocol prefixsocks5hmeans that hostnames are resolved by the proxy. The symbols%25,%3Aand%40are URL decoded into%,:and@respectively, if present in the username or password.
If username is not given, then no authentication is attempted. If the port is not given, then the default of 1080 is used.
If the host is given as an IPv6 address, it must be enclosed in square brackets, e.g. socks5h://[::1]:1080. Note that square brackets have special meaning in some shells, so the proxy url may need quoting in double or single quotes.
More SOCKS versions may be available in the future, depending on demand, and will use different protocol prefixes as described in curl(1).
--pskβ Provide the hexadecimal (no leading0x) pre-shared-key matching the one used on the broker to use TLS-PSK encryption support.--psk-identitymust also be provided to enable TLS-PSK.--psk-identityβ The client identity to use with TLS-PSK support. This may be used instead of a username if the broker is configured to do so.-q,--qosβ Specify the quality of service to use for messages, from0,1and2. Defaults to1.--quietβ If this argument is given, no runtime errors will be printed. This excludes any error messages given in case of invalid user input (e.g. using--portwithout a port).--tls-alpnβ Provide a protocol to use when connecting to a broker that has multiple protocols available on a single port, e.g. MQTT and WebSockets.--tls-engineβ A valid openssl engine id. These can be listed with theopenssl enginecommand. See also--keyform.--tls-engine-kpass-sha1β SHA1 of the private key password when using an TLS engine. Some TLS engines such as the TPM engine may require the use of a password in order to be accessed. This option allows a hex encoded SHA1 hash of the password to the engine directly, instead of the user being prompted for the password. See also--tls-engine.--tls-use-os-certsβ If used, this will load and trust the OS provided CA certificates. This can be used in conjunction with--cafileand--capathand can be used on its own to enable TLS mode. This will be set by default if-L mqtts://...is used, or if port is8883and no other certificate options are used.--tls-versionβ Choose which TLS protocol version to use when communicating with the broker. Valid options aretlsv1.3andtlsv1.2. The default value istlsv1.2. Must match the protocol version used by the broker.-u,--usernameβ Provide a username to be used for authenticating with the broker. See also the--pwargument.--unixβ Connect to a broker through a local unix domain socket instead of a TCP socket. This is a replacement for-hand-L. For example:
mosquitto_ctrl --unix /tmp/mosquitto.sock ...
See the socket_domain option in mosquitto.conf(5) to configure Mosquitto to listen on a unix socket.
-V,--protocol-versionβ Specify which version of the MQTT protocol should be used when connecting to the remote broker. Can be5,311,31, or the more verbosemqttv5,mqttv311, ormqttv31. Defaults to311.
β¨ PROPERTIES β¨
okay so the -D / --property option is literally how you add properties to different stages of the mosquitto_ctrl run. bestie, hereβs exactly which properties each command supports β no guessing, no vibes-only π
Connect π«Ά
authentication-dataβ binary data (note: treated as a string)authentication-methodβ UTF-8 string pairmaximum-packet-sizeβ 32-bit unsigned integerreceive-maximumβ 16-bit unsigned integerrequest-problem-informationβ 8-bit unsigned integerrequest-response-informationβ 8-bit unsigned integersession-expiry-intervalβ 32-bit unsigned integer, note: use-xinsteadtopic-alias-maximumβ 16-bit unsigned integeruser-propertyβ UTF-8 string pair
Publish π
content-typeβ UTF-8 stringcorrelation-dataβ binary data (note: treated as a string)message-expiry-intervalβ 32-bit unsigned integerpayload-format-indicatorβ 8-bit unsigned integerresponse-topicβ UTF-8 stringtopic-aliasβ 16-bit unsigned integeruser-propertyβ UTF-8 string pair
Disconnect πΈ
session-expiry-intervalβ 32-bit unsigned integeruser-propertyβ UTF-8 string pair
Will properties π¦
content-typeβ UTF-8 stringcorrelation-dataβ binary data (note: treated as a string)message-expiry-intervalβ 32-bit unsigned integerpayload-format-indicatorβ 8-bit unsigned integerresponse-topicβ UTF-8 stringuser-propertyβ UTF-8 string pairwill-delay-intervalβ 32-bit unsigned integer
π¦ EXIT STATUS π¦
Zero on success, or non-zero on error. If the connection is refused by the broker at the MQTT level, then the exit code is the CONNACK reason code. If another error occurs, the exit code is a libmosquitto return value.
MQTT v3.1.1 CONNACK codes π
0β Success1β Connection refused: Bad protocol version2β Connection refused: Identifier rejected3β Connection refused: Server unavailable4β Connection refused: Bad username/password5β Connection refused: Not authorized
MQTT v5 CONNACK codes π₯
0β Success128β Unspecified error129β Malformed packet130β Protocol error131β Implementation specific error132β Unsupported protocol version133β Client ID not valid134β Bad username or password135β Not authorized136β Server unavailable137β Server busy138β Banned139β Server shutting down140β Bad authentication method141β Keep alive timeout142β Session taken over143β Topic filter invalid144β Topic name invalid147β Receive maximum exceeded148β Topic alias invalid149β Packet too large148β Message rate too high151β Quota exceeded152β Administrative action153β Payload format invalid154β Retain not supported155β QoS not supported156β Use another server157β Server moved158β Shared subscriptions not supported159β Connection rate exceeded160β Maximum connect time161β Subscription IDs not supported162β Wildcard subscriptions not supported
and yes, 148 really is listed twice up there β the page said it twice, so Iβm saying it twice π«Ά
Other codes π
27β Timed out waiting for message
πΏ ENVIRONMENT VARIABLES πΏ
MOSQUITTO_UNSAFE_ALLOW_SYMLINKS π
By default, sensitive file with a path including a symbolic link will be refused to be loaded. Set this environment variable to any value to allow load files through symbolic links.
β οΈ note that making use of this variable could expose you to symlink attacks and so it should only be used in cases where you are absolutely sure this is not a risk. like, fr fr, be careful.
π BUGS π
mosquitto bug information can be found at https://github.com/eclipse-mosquitto/mosquitto/issues β thatβs the spot for bug gossip π
π SEE ALSO π
mosquitto(7)mqtt(7)mosquitto_ctrl_shell(1)mosquitto_rr(1)mosquitto_pub(1)mosquitto_sub(1)mosquitto(8)libmosquitto(3)mosquitto-tls(7)
π AUTHOR π
Roger Light <roger@atchoo.org>
later bestie! this iconic page came from the Mosquitto Project, dated 02/09/2026, and its manual-page tag is MOSQUITTO_CTRL(1) β slay π
β¨
π¦ where this page comes from
- alpine 3.24: mosquitto-doc 2.1.2-r1 Β· EPL-1.0 OR EPL-2.0
- fedora 44: mosquitto 2.1.2-1.fc44 Β· EPL-2.0
- fedora 44: mosquitto 2.1.2-1.fc44 Β· EPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms