RabbitMQ failed to start, TCP connection succeeded but Erlang distribution failed
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
RabbitMQ is a widely adopted open-source message broker that uses the Advanced Message Queuing Protocol (AMQP). An essential component of RabbitMQ's architecture is the Erlang runtime, which it requires to handle messaging processes effectively. Situations where RabbitMQ's TCP connections are successful but Erlang distribution (distribution of messages between nodes in a cluster) fails, can cause significant disruptions in service. This article delves into these issues, their common causes, and potential solutions.
Understanding Erlang Distribution
Erlang distribution is a mechanism used to communicate between Erlang nodes. It forms the backbone for clustering in RabbitMQ, enabling nodes to share data, synchronize state, and handle message routing transparently. The issue “TCP connection succeeded but Erlang distribution failed” typically indicates that while the lower level network connection (TCP) between nodes is established, the higher-level Erlang processes are unable to successfully communicate.
Common Causes and Solutions
1. Incorrect Hostname Configuration
Erlang nodes identify each other via hostnames. If the hostnames are incorrectly configured or not resolvable, the nodes won’t be able to establish an Erlang connection even if the TCP layer can connect.
Solution:
Ensure that all hostnames are correctly configured in the RabbitMQ configuration file and are resolvable from each node in the cluster.
2. Firewall Rules
Firewalls blocking the ports used by Erlang can prevent nodes from communicating, despite an established TCP/IP connection.
Solution:
Configure the firewall to allow traffic on the ports used by Erlang (default is 25672 for RabbitMQ).
3. Version Mismatch between Nodes
All nodes in a RabbitMQ cluster should run the same version of RabbitMQ and Erlang. A mismatch can lead to failure in Erlang distribution.
Solution:
Ensure uniformity in RabbitMQ and Erlang versions across all cluster nodes.
4. Cookie Mismatch
Erlang uses a "cookie" for authentication among nodes in a cluster. If these cookies don’t match, nodes will not be able to communicate.
Solution:
Verify and synchronize the .erlang.cookie file across all nodes ensuring that they are identical and have the proper permissions (typically 400 or read-only by the owner).
Debugging the Issue
- Check Logs: Start by examining the RabbitMQ and Erlang logs often found in
/var/log/rabbitmq/. These logs can provide insights into what might be causing the distribution failure. - Erlang Ping Test (
net_adm:ping()): Use the Erlang shell to ping other nodes. If the ping returnspong, the nodes can communicate at the Erlang level, else, it points to an issue in Erlang-level connectivity. - Using
rabbitmqctl: The commandrabbitmqctl cluster_statuscan be useful to examine the cluster's state and check connectivity statuses.
Summary Table
| Issue | Cause | Solution |
| Hostname Configuration | Incorrect or unresolvable hostnames | Correct hostname settings and DNS |
| Firewall Rules | Blocking Erlang ports | Modify firewall to allow Erlang ports |
| Version Mismatch | Different RabbitMQ/Erlang versions on nodes | Standardize versions across nodes |
| Cookie Mismatch | Different Erlang cookies on nodes | Sync .erlang.cookie files |
Additional Insights
When configuring RabbitMQ clusters, additional factors such as network latency, hardware reliability, and proper synchronization of configuration files should be considered. Regular checks and monitoring of both RabbitMQ and network health will help preemptively identify and solve potential issues that could lead to a failure in Erlang distribution.
Understanding and resolving issues related to Erlang distribution failures in RabbitMQ setups is crucial for maintaining a robust and efficient messaging system. Correct configuration settings, adequate firewall handling, version synchronization, and cookie management are imperative to avoid such disruptions and ensure seamless communication between nodes.
Related reading
- RabbitMQ fails on Error unable to connect to node rabbit@TPAJ05421843 nodedown
- RabbitMQ fails to start
- RabbitMQ fast producer and slow consumer
- Rabbitmq File Descriptor Limit
- RabbitMQ IOError Socket
- RabbitMQ Management Over HTTPS and Nginx
- RabbitMQ handshake error when attempting to use SSL certificates
- RabbitMQ Hello World example gives Connection Refused

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.