How to Install Kafka on Mac?
Summarize this article with:
✨ AI Generated Summary
Installing Kafka on macOS takes about 10 minutes. This guide covers both Homebrew (fastest) and manual installation methods.
TL;DR
- Kafka installs quickly on macOS using Homebrew, which is the fastest and easiest option for local development.
- Java 11 or newer is required before Kafka will run, regardless of installation method.
- You can choose Zookeeper or KRaft mode, but KRaft is the recommended option for new Kafka 3.3+ setups.
- Once Kafka is running locally, you can immediately create topics, produce messages, and start building data pipelines.
What do you need before installing Kafka?
Kafka requires Java 11 or later. Check your Java version:
java -versionNo Java? Install it via Homebrew:
brew install openjdk@17How do you install Kafka with Homebrew?
Homebrew handles dependencies and configuration automatically. This is the recommended approach for local development.
1. Install Kafka
brew install kafkaThis installs both Kafka and Zookeeper (required for Kafka versions before 3.3).
2. Start Zookeeper
brew services start zookeeper3. Start Kafka
brew services start kafkaKafka now runs on localhost:9092.
How do you install Kafka manually?
Manual installation gives you more control over versions and configuration.
1. Download Kafka
Download the latest binary from the Apache Kafka website. Choose the Scala 2.13 version:
curl -O https://downloads.apache.org/kafka/3.6.1/kafka_2.13-3.6.1.tgz2. Extract and move to /opt
tar -xzf kafka_2.13-3.6.1.tgz
sudo mv kafka_2.13-3.6.1 /opt/kafka3. Add Kafka to your PATH
Add this line to your ~/.zshrc or ~/.bash_profile:
export PATH="$PATH:/opt/kafka/bin"Reload your shell:
source ~/.zshrc4. Start Zookeeper
zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties5. Start Kafka (new terminal)
kafka-server-start.sh /opt/kafka/config/server.propertiesHow do you run Kafka without Zookeeper (KRaft mode)?
Kafka 3.3+ supports KRaft mode, which removes the Zookeeper dependency.
1. Generate a cluster ID
KAFKA_CLUSTER_ID="$(kafka-storage.sh random-uuid)"2. Format the storage directory
kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c /opt/kafka/config/kraft/server.properties3. Start Kafka
kafka-server-start.sh /opt/kafka/config/kraft/server.propertiesHow do you verify Kafka is running?
Create a test topic and send a message:
1. Create a topic
kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 12. List topics
kafka-topics.sh --list --bootstrap-server localhost:90923. Send a test message
echo "Hello Kafka" | kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:90924. Read the message
kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092You should see "Hello Kafka" in the output. Press Ctrl+C to exit.
What are common installation issues?
Port 9092 already in use: Another process is using the Kafka port. Check with lsof -i :9092 and kill the conflicting process.
Zookeeper connection refused: Zookeeper must start before Kafka. Verify it's running with brew services list or check port 2181.
Java version mismatch: Kafka 3.x requires Java 11+. Run java -version to verify.
Broker not available: Wait 30 seconds after starting Kafka. The broker needs time to register with Zookeeper.
What's next after installing Kafka?
With Kafka running locally, you can start building data pipelines. Airbyte provides 600+ pre-built connectors to move data from any source into Kafka or from Kafka to your data warehouse. Try Airbyte to connect your first data source in minutes.
Frequently Asked Questions
Does Kafka work on Apple Silicon (M1/M2/M3)?
Yes. Both Homebrew and manual installations work on Apple Silicon Macs. Kafka runs natively without Rosetta emulation.
How much memory does Kafka need?
Kafka defaults to 1GB heap size. For local development, this is sufficient. Adjust with KAFKA_HEAP_OPTS="-Xmx512M -Xms512M" if you're running on a resource-constrained machine.
Should I use Zookeeper or KRaft mode?
KRaft mode is production-ready as of Kafka 3.3. Use it for new projects. Existing Zookeeper deployments work fine but will eventually need migration as Zookeeper support is being phased out.
How do I stop Kafka and Zookeeper?
With Homebrew: brew services stop kafka && brew services stop zookeeper
With manual installation: Press Ctrl+C in each terminal window, or use kafka-server-stop.sh and zookeeper-server-stop.sh.
Can I run multiple Kafka brokers locally?
Yes. Copy the server.properties file, change the broker.id, listeners, and log.dirs values, then start each broker with its own config file. This is useful for testing replication.
Where are Kafka logs stored?
Homebrew installation: /opt/homebrew/var/lib/kafka-logs
Manual installation: /tmp/kafka-logs by default (configurable via log.dirs in server.properties)
.webp)
