I have a two-nodes Kafka cluster (EC2 instances) where each node is used as a separate broker. When I run a producer on the leader instance with the following command:
Make the replication factor 2 for topic test
and you won't get this exception anymore.
Since you have a 2 broker cluster, execute the command below to produce messages:
kafka-console-producer.sh --broker-list localhost:9092,localhost:9093 --topic test
This will send messages to both of the brokers in the clusters.