Install kafka in macos catalina using brew

if you do not have brew installed on your mac, Install homebrew on your mac by running the following command on your Terminal.

$ /usr/bin/ruby -e “$(curl -fsSL"

Install kafka in MacOS Catalina

First install openjdk 8 using brew cask and then install kakfa.

$ brew cask install homebrew/cask-versions/adoptopenjdk8
$ brew install kafka

When the installation completes, It will show you something like below

==> Downloading
Already downloaded: /Users/myuser/Library/Caches/Homebrew/downloads/fa99441b0e60bc155f3b32840457e399e1d7659514a8767408a4bf84b5ec83c7--kafka-2.4.0.catalina.bottle.tar.gz
==> Pouring kafka-2.4.0.catalina.bottle.tar.gz
==> Caveats
To have launchd start kafka now and restart at login:
  brew services start kafka
Or, if you don't want/need a background service you can just run:
  zookeeper-server-start /usr/local/etc/kafka/ & kafka-server-start /usr/local/etc/kafka/
==> Summary
🍺  /usr/local/Cellar/kafka/2.4.0: 186 files, 59.5MB

Start zookeeper & kafka as a service

$ brew services start zookeeper
$ brew services start kafka

Stop zookeeper & kafka service

$ brew services stop zookeeper
$ brew services stop kafka

If you do not want to run kafka & zookeeper as a service use below commands

$ zookeeper-server-start /usr/local/etc/kafka/
$ kafka-server-start /usr/local/etc/kafka/

If you face any error in starting kafka, you will have configure listeners in /usr/local/etc/kafka/ config file,

vi /usr/local/etc/kafka/

uncomment and change the values like below


Check if kafka is functioning properly

Create test topic
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Start kafka consumer console
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
Start kafka producer console

Once the producer starts enter any message and press enter.

kafka-console-producer --broker-list localhost:9092 --topic test