# How to install Apache Kafka on Windows

*Install and run Kafka on Windows in 20 minutes*

This guide walks you through installing Apache Kafka with ZooKeeper on Windows using WSL2 (Windows Subsystem for Linux). By the end, you'll have a working single-node Kafka cluster for development.

**What you'll learn:**
- How to set up WSL2 on Windows
- How to install Java 11 (required dependency)
- How to download and configure Kafka
- How to start ZooKeeper and Kafka

> **Native Windows is not recommended**
> Kafka has known issues when running directly on Windows due to missing POSIX features. Always use WSL2 or [Docker](https://www.conduktor.io/kafka/how-to-start-kafka-using-docker) for Windows installations.

This guide uses ZooKeeper mode for maximum compatibility. For KRaft mode (without ZooKeeper), see the [Windows KRaft installation guide](https://www.conduktor.io/kafka/how-to-install-apache-kafka-on-windows-without-zookeeper-kraft-mode).

## Installation overview

![Windows Kafka install flow: install WSL2, install Java 11, download Kafka, disable IPv6, start ZooKeeper, start Kafka](https://www.conduktor.io/assets/kafka/diagrams/how-to-install-apache-kafka-on-windows.svg)

```mermaid
flowchart LR
    A[Install WSL2] --> B[Install Java 11]
    B --> C[Download Kafka]
    C --> D[Disable IPv6]
    D --> E[Start ZooKeeper]
    E --> F[Start Kafka]
```

## Step 1: Install WSL2

WSL2 provides a Linux environment on Windows without a virtual machine.

Open **PowerShell as Administrator** and run:

```powershell
wsl --install
```

This installs Ubuntu by default. Restart your computer when prompted.

After restart, open Ubuntu from the Start menu and create a Linux username and password.

> For troubleshooting WSL2 issues, see the [Microsoft troubleshooting guide](https://docs.microsoft.com/en-us/windows/wsl/troubleshooting).

## Step 2: Disable IPv6 on WSL2

WSL2 has a [networking issue](https://github.com/microsoft/WSL/issues/4851) that prevents external programs from connecting to Kafka. Disable IPv6 to fix this:

```bash
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
```

## Step 3: Install Java JDK 11

In your WSL2 Ubuntu terminal:

```bash
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
sudo apt-get update
sudo apt-get install -y java-11-amazon-corretto-jdk
```

Verify the installation:

```bash
java -version
```

Expected output:
```
openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment Corretto-11.0.10.9.1 (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode)
```

## Step 4: Download and extract Kafka

```bash
wget https://archive.apache.org/dist/kafka/3.0.0/kafka_2.13-3.0.0.tgz
tar -xzf kafka_2.13-3.0.0.tgz
mv kafka_2.13-3.0.0 ~
```

Or download manually from [kafka.apache.org/downloads](https://kafka.apache.org/downloads).

## Step 5: Start ZooKeeper

ZooKeeper has to be running before Kafka starts.

```bash
~/kafka_2.13-3.0.0/bin/zookeeper-server-start.sh ~/kafka_2.13-3.0.0/config/zookeeper.properties
```

> Add the `-daemon` flag to run ZooKeeper in the background.

Keep this terminal window open.

## Step 6: Start Kafka

Open a **new WSL2 terminal window** and run:

```bash
~/kafka_2.13-3.0.0/bin/kafka-server-start.sh ~/kafka_2.13-3.0.0/config/server.properties
```

Keep this terminal window open. Kafka is now running at `localhost:9092`.

## Step 7: Configure PATH

Add Kafka binaries to your PATH:

```bash
echo 'export PATH="$PATH:$HOME/kafka_2.13-3.0.0/bin"' >> ~/.bashrc
source ~/.bashrc
```

Verify the setup:

```bash
kafka-topics.sh --version
```

## Frequently asked questions

**Can I run Kafka directly on Windows without WSL2?**

Technically yes, but you will encounter issues. Kafka lacks support for certain Windows-specific behaviors, leading to problems when [deleting topics](https://issues.apache.org/jira/browse/KAFKA-8811) or during log segment rotation.

**Can I use Windows Kafka binaries with WSL2 Kafka?**

Yes. You can download Kafka binaries on Windows and use commands like `kafka-topics.bat` against your cluster running in WSL2.

> **See it in practice with Conduktor**
> [Conduktor Console](https://docs.conduktor.io/guide/conduktor-in-production/admin/configure-clusters) can connect to your WSL2 Kafka cluster at `localhost:9092` from Windows for visual topic management.

## Next steps

- [Windows KRaft installation](https://www.conduktor.io/kafka/how-to-install-apache-kafka-on-windows-without-zookeeper-kraft-mode) for a ZooKeeper-free setup
- [CLI tutorials](https://www.conduktor.io/kafka/kafka-cli-tutorial) to create topics and produce messages
- [Docker setup](https://www.conduktor.io/kafka/how-to-start-kafka-using-docker) for an alternative containerized setup
