How to Install and Set Up Kafka 4.0.0 on macOS with Homebrew(2025)
April 30, 2025 · 2 min read · Originally on Medium
These instructions are tailored for macOS users
When trying to install and run Kafka on macOS using Homebrew, I ran into a lot of small annoyances — missing files, outdated commands, and inconsistent docs. So I decided to write this post as a no-nonsense guide that just works. If you’re using Kafkaesque (Kafka 4.0.0+) on an M1/M2 Mac, this is for you.

Kafka is a distributed event streaming platform capable of handling trillions of events a day. It’s widely used for real-time data processing, event sourcing, and stream processing. If you’re on macOS and want to quickly set up Kafka, Homebrew makes the process seamless. In this article, we’ll walk you through the steps of installing Kafka via Homebrew and setting up a Kafka cluster on your Mac.
Prerequisites
- Homebrew: Ensure you have Homebrew installed. If not, install it via the following command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 1: Install Kafka via Homebrew
Homebrew allows you to install Kafka quickly. To install Kafka on your Mac, run:
brew install kafka
This command will automatically install Kafka along with its dependencies.
Step 2: Verify Kafka Installation
After Kafka is installed, you can verify its installation by checking the version:
kafka -version
You should see output showing the installed Kafka version.
Step 3: Set Up Kafka Storage
Before starting your Kafka broker, you need to initialize the storage. Kafka uses kafka-storage to manage its storage configurations. Since Kafka is installed through Homebrew, you’ll use the kafka-storage binary to handle storage-related tasks.
To generate a random Kafka cluster ID, run:
KAFKA_CLUSTER_ID="$(kafka-storage random-uuid)"
This will generate a unique ID for your Kafka cluster.
Step 4: Format Kafka Storage
Now that you have the cluster ID, you can format Kafka’s storage. Run the following command:
kafka-storage format --standalone -t $KAFKA_CLUSTER_ID -c /opt/homebrew/etc/kafka/server.properties
Explanation of the command:
- kafka-storage: The binary used to manage Kafka storage.
- format: The action to format Kafka’s storage.
- --standalone: Configures Kafka as a standalone broker.
- -t $KAFKA_CLUSTER_ID: Specifies the Kafka cluster ID (the one you generated earlier).
- -c /opt/homebrew/etc/kafka/server.properties: Specifies the path to the Kafka configuration file.
Step 5: Start Kafka Server
With Kafka storage formatted, you can now start the Kafka server. To do so, run the following command:
kafka-server-start /opt/homebrew/etc/kafka/server.properties
This command will start Kafka using the configuration file located at /opt/homebrew/etc/kafka/server.properties. If you’ve customized the file path, make sure to adjust the path accordingly.
If you prefer using the script, you can run:
/opt/homebrew/opt/kafka/bin/kafka-server-start.sh /opt/homebrew/etc/kafka/server.properties
This will start Kafka using the script from the Homebrew Kafka installation.
Step 6: Verify Kafka is Running
Once Kafka starts, you can verify that it’s running by listing the Kafka topics:
kafka-topics --list --bootstrap-server localhost:9092
If everything is set up correctly, you should see an empty list (no topics created yet).
Conclusion
You have successfully installed and set up Kafka on your macOS machine using Homebrew. This setup is perfect for local development and testing, and it can be easily extended for production use.
Kafka is an incredibly powerful tool for building real-time data pipelines and streaming applications. Once Kafka is up and running, you can start integrating it with other systems, producing messages to topics, and consuming messages in real-time.
If you encounter any issues or need further assistance, feel free to reach out in the comments below!
Nisal Gunawardhana.
Email — contact@nisalgunawardhana.com | web — Nisal Gunawardhana LinkedIn | Instagram | Facebook | YouTube | X(Twitter) | GitHub
Enjoyed this? Follow me on Medium.
New articles on AI, cloud, GitHub and building software.