> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/integrations/builtin/credentials/mqtt.md).

# MQTT credentials

You can use these credentials to authenticate the following nodes:

* [MQTT](/integrations/builtin/app-nodes/n8n-nodes-base.mqtt.md)
* [MQTT Trigger](/integrations/builtin/trigger-nodes/n8n-nodes-base.mqtttrigger.md)

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Install an [MQTT broker](https://mqtt.org/).

MQTT provides a list of Servers/Brokers at [MQTT Software](https://mqtt.org/software/).

## Supported authentication methods <a href="#supported-authentication-methods" id="supported-authentication-methods"></a>

* Broker connection

## Related resources <a href="#related-resources" id="related-resources"></a>

Refer to [MQTT's documentation](https://mqtt.org/) for more information about the MQTT protocol.

Refer to your broker provider's documentation for more detailed configuration and details.

## Using broker connection <a href="#using-broker-connection" id="using-broker-connection"></a>

To configure this credential, you'll need:

* Your MQTT broker's **Protocol**
* The **Host**
* The **Port**
* A **Username** and **Password** to authenticate with
* If you're using **SSL**, the relevant certificates and keys

To set things up:

1. Select the broker's **Protocol**, which determines the URL n8n uses. Options include:
   * **Mqtt**: Begin the URL with the standard `mqtt:` protocol.
   * **Mqtts**: Begin the URL with the secure `mqtts:` protocol.
   * **Ws**: Begin the URL with the WebSocket `ws:` protocol.
2. Enter your broker **Host**.
3. Enter the **Port** number n8n should use to connect to the broker host.
4. Enter the **Username** to log into the broker as.
5. Enter that user's **Password**.
6. If you want to receive QoS 1 and 2 messages while offline, turn off the **Clean Session** toggle.
7. Enter a **Client ID** you'd like the credential to use. If you leave this blank, n8n will generate one for you. You can use a fixed or expression-based Client ID.
   * Client IDs can be useful to identify and track connection access. n8n recommends using something with `n8n` in it for easier auditing.
8. If your MQTT broker uses SSL, turn the **SSL** toggle on. Once you turn it on:
   1. Select whether to use **Passwordless** connection with certificates, which is like the SASL mechanism EXTERNAL. If turned on:
      1. Select whether to **Reject Unauthorized Certificate**: If turned off, n8n will connect even if the certificate validation fails.
      2. Add an SSL **Client Certificate**.
      3. Add an SSL **Client Key** for the Client Certificate.
   2. One or more SSL **CA Certificates**.

Refer to your MQTT broker provider's documentation for more detailed configuration instructions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.n8n.io/integrations/builtin/credentials/mqtt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
