NATS icon

NATS

NATS

Overview

This node integrates with the NATS messaging system, allowing users to publish messages to a NATS server. The primary operation supported here is Publish, which sends a message with a specified subject and payload to the NATS server.

Common scenarios for this node include:

  • Sending event notifications or alerts within distributed systems.
  • Broadcasting messages to multiple subscribers in real-time applications.
  • Integrating n8n workflows with microservices that communicate via NATS.

For example, you could use this node to publish a JSON payload notifying other services about a new user registration or to send commands to IoT devices subscribed to specific subjects.

Properties

Name Meaning
Subject The subject (topic) on the NATS server to which the message will be published.
Payload Content Type The type of the payload content. Options: "String" for plain text payloads, or "N8n Binary Data" for binary data payloads.
Payload The actual message content as a string. Used when Payload Content Type is "String".
Payload Binary Property Name The name of the binary property from input data to use as the payload. Used when Payload Content Type is "N8n Binary Data".
Headers Optional HTTP-style headers to include with the published message. Supports multiple key-value pairs.

Output

The node outputs an array of JSON objects representing the result of each publish action. Each output item corresponds to an input item processed by the node.

  • The json field contains metadata about the publish operation, such as success confirmation or error details if publishing failed.
  • If binary data is used as payload, it is sent as-is to the NATS server; however, the output does not contain binary data itself but rather the status/result of the publish operation.

Dependencies

  • Requires access to a NATS server instance.
  • Needs an API authentication token or credentials configured in n8n to connect securely to the NATS server.
  • Uses the official NATS client library internally (bundled in the node).

Troubleshooting

  • Connection errors: Ensure the NATS server URL and credentials are correctly configured. Network issues or firewall restrictions can prevent connection.
  • Publish failures: Check that the subject is valid and that the payload matches the expected format (string or binary). Invalid payload types or missing required properties may cause errors.
  • Headers ignored: Some NATS servers or configurations might not support custom headers; verify server capabilities if headers do not appear to have effect.
  • Binary payload issues: Confirm that the binary property name matches exactly the input binary data property; otherwise, the payload will be empty or invalid.

Links and References

Discussion