How to Install Kafka on Mac?

Install Apache Kafka on macOS in 10 minutes. Step-by-step guide covering Homebrew installation, manual setup, KRaft mode, and verification commands.

Summarize with AI:

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:

CODE
java -version

No Java? Install it via Homebrew:

CSS
brew install openjdk@17

How do you install Kafka with Homebrew?

Homebrew handles dependencies and configuration automatically. This is the recommended approach for local development.

1. Install Kafka

CODE
brew install kafka

This installs both Kafka and Zookeeper (required for Kafka versions before 3.3).

2. Start Zookeeper

SQL
brew services start zookeeper

3. Start Kafka

SQL
brew services start kafka

Kafka 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:

BASH
curl -O https://downloads.apache.org/kafka/3.6.1/kafka_2.13-3.6.1.tgz

2. Extract and move to /opt

BASH
tar -xzf kafka_2.13-3.6.1.tgz
sudo mv kafka_2.13-3.6.1 /opt/kafka

3. Add Kafka to your PATH

Add this line to your ~/.zshrc or ~/.bash_profile:

BASH
export PATH="$PATH:/opt/kafka/bin"

Reload your shell:

BASH
source ~/.zshrc

4. Start Zookeeper

SWIFT
zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties

5. Start Kafka (new terminal)

SWIFT
kafka-server-start.sh /opt/kafka/config/server.properties

How do you run Kafka without Zookeeper (KRaft mode)?

Kafka 3.3+ supports KRaft mode, which removes the Zookeeper dependency.

1. Generate a cluster ID

INI
KAFKA_CLUSTER_ID="$(kafka-storage.sh random-uuid)"

2. Format the storage directory

SWIFT
kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c /opt/kafka/config/kraft/server.properties

3. Start Kafka

SWIFT
kafka-server-start.sh /opt/kafka/config/kraft/server.properties

How do you verify Kafka is running?

Create a test topic and send a message:

1. Create a topic

CSS
kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1

2. List topics

CSS
kafka-topics.sh --list --bootstrap-server localhost:9092

3. Send a test message

BASH
echo "Hello Kafka" | kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092

4. Read the message

CSS
kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092

You 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)

Integrate with 600+ apps using Airbyte

Move data from 600+ sources into warehouses, lakes, and beyond. Set up pipelines in minutes with pre-built connectors and the Connector Builder.