Install Apache Kafka on Ubuntu for a Local Kafka Broker
To install Apache Kafka on Ubuntu, you need a supported Java JDK and the Kafka binary package. This tutorial shows the current local setup flow using Kafka in KRaft mode, and it also keeps the older ZooKeeper-based startup steps for readers who are working with older Kafka releases.
For a local development machine, the usual flow is simple: install Java, download Kafka, extract it, format the Kafka storage directory, start the broker, and verify the setup with a topic, producer, and consumer.

Apache Kafka Ubuntu installation requirements
Before you start, make sure that you have:
- An Ubuntu system with terminal access.
- A user account with
sudopermission for installing packages. - Java installed. Current Apache Kafka quickstart builds require Java 17 or newer, while older Kafka versions may run with older Java releases.
- Internet access to download Kafka from the Apache Kafka downloads page.
Install Java JDK for Apache Kafka on Ubuntu
Open a terminal and run the following command :
$ sudo apt-get install default-jdk
On newer Ubuntu systems, you can explicitly install OpenJDK 17 with the following command.
sudo apt update
sudo apt install -y openjdk-17-jdk
To verify the installation of java, run the following command in the terminal :
$ java -version
The output should show the version of java installed, similar to below verbose :
kafkauser@tutorialkart:~$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
If you installed Java 17, your output will show a 17.x version instead of the older Java 8 output shown above.
Download and extract Apache Kafka binary on Ubuntu
Download the latest Apache Kafka from https://kafka.apache.org/downloads under Binary downloads.
The official Kafka quickstart uses the Scala 2.13 binary package for current releases. The version in the command below is only an example; replace it with the current file name shown on the Apache Kafka downloads page.
wget https://dlcdn.apache.org/kafka/4.3.0/kafka_2.13-4.3.0.tgz
tar -xzf kafka_2.13-4.3.0.tgz
cd kafka_2.13-4.3.0
Extract the .tgz file.
Navigate to root of Apache Kafka folder and open a Terminal. Or Open a Terminal and navigate to the root directory of Apache Kafka.
kafkauser@tutorialkart:/home/kafkauser/kafka/kafka_2.11-0.11.0.0$ ls
bin config libs LICENSE logs NOTICE site-docs
The directory name may be different on your system. For example, a current Kafka download may use a folder such as kafka_2.13-4.3.0, while the older example above uses kafka_2.11-0.11.0.0.
Start Apache Kafka on Ubuntu in KRaft mode
Current Apache Kafka local quickstart uses KRaft mode, so you do not start a separate ZooKeeper process for a basic local broker. From the Kafka root directory, generate a cluster ID and format the storage directory first.
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
bin/kafka-storage.sh format --standalone -t "$KAFKA_CLUSTER_ID" -c config/server.properties
Then start the Kafka broker from the same Kafka directory.
bin/kafka-server-start.sh config/server.properties
Keep this terminal open while you test Kafka. The broker listens on localhost:9092 by default in a local setup.
Verify Apache Kafka installation with a topic, producer, and consumer
Open another terminal from the Kafka root directory and create a test topic.
bin/kafka-topics.sh --create --topic tutorialkart-events --bootstrap-server localhost:9092
Describe the topic to confirm that Kafka created it.
bin/kafka-topics.sh --describe --topic tutorialkart-events --bootstrap-server localhost:9092
Start a console producer and type a few messages. Each line is sent as one Kafka event.
bin/kafka-console-producer.sh --topic tutorialkart-events --bootstrap-server localhost:9092
>Hello Kafka from Ubuntu
>Second test message
Open another terminal and start a console consumer from the beginning of the topic.
bin/kafka-console-consumer.sh --topic tutorialkart-events --from-beginning --bootstrap-server localhost:9092
You should see the messages that you entered through the producer.
Hello Kafka from Ubuntu
Second test message
Check Apache Kafka version in Linux terminal
To get the Kafka version in Linux, run one of the Kafka command-line tools with the --version option from the Kafka root directory.
bin/kafka-topics.sh --version
This is useful when the extracted folder name, documentation, and broker output do not clearly show which Kafka binary you are using.
Start ZooKeeper for older Apache Kafka releases
Older Apache Kafka releases used ZooKeeper for cluster metadata. If you are installing a current Kafka release for local learning, use the KRaft steps above. Use the ZooKeeper steps below only when you are working with an older Kafka package or an older tutorial that specifically requires ZooKeeper.
Apache Kafka depends on Zookeeper for cluster management. Hence, prior to starting Kafka, Zookeeper has to be started. There is no need to explicitly install Zookeeper, as it comes included with Apache Kafka.
From the root of Apache Kafka, run the following command to start Zookeeper :
~$ bin/zookeeper-server-start.sh config/zookeeper.properties
The zookeeper should be started with a similar following trace in the output.
kafkauser@tutorialkart:/home/kafkauser/kafka/kafka_2.11-0.11.0.0~$ bin/zookeeper-server-start.sh config/zookeeper.properties
[2017-08-14 10:34:02,974] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2017-08-14 10:34:03,035] INFO autopurge.snapRetainCount set to 3 (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-08-14 10:34:03,036] INFO autopurge.purgeInterval set to 0 (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-08-14 10:34:03,036] INFO Purge task is not scheduled. (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-08-14 10:34:03,036] WARN Either no config or no quorum defined in config, running in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2017-08-14 10:34:03,061] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2017-08-14 10:34:03,083] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)
[2017-08-14 10:34:03,131] INFO Server environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT (org.apache.zookeeper.server.ZooKeeperServer)
Start Apache Kafka server with ZooKeeper on older releases
Open another Terminal and run the following command from the root of Apache Kafka to start Apache Kafka.
~$ bin/kafka-server-start.sh config/server.properties
Following should be the end of trace stating that Kafka server is started.
[2017-08-14 10:38:11,070] INFO Cluster ID = xp4xG4pbSEGnLXXW5hB8qA (kafka.server.KafkaServer)
[2017-08-14 10:38:11,076] WARN No meta.properties file under dir /tmp/kafka-logs/meta.properties (kafka.server.BrokerMetadataCheckpoint)
[2017-08-14 10:38:11,198] INFO [ThrottledRequestReaper-Fetch]: Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2017-08-14 10:38:11,199] INFO [ThrottledRequestReaper-Produce]: Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2017-08-14 10:38:11,201] INFO [ThrottledRequestReaper-Request]: Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2017-08-14 10:38:11,353] INFO Log directory '/tmp/kafka-logs' not found, creating it. (kafka.log.LogManager)
[2017-08-14 10:38:11,381] INFO Loading logs. (kafka.log.LogManager)
[2017-08-14 10:38:11,391] INFO Logs loading complete in 10 ms. (kafka.log.LogManager)
[2017-08-14 10:38:11,460] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)
[2017-08-14 10:38:11,463] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2017-08-14 10:38:11,552] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2017-08-14 10:38:11,555] INFO [Socket Server on Broker 0], Started 1 acceptor threads (kafka.network.SocketServer)
[2017-08-14 10:38:11,588] INFO [ExpirationReaper-0-Produce]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,590] INFO [ExpirationReaper-0-Fetch]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,592] INFO [ExpirationReaper-0-DeleteRecords]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,691] INFO [ExpirationReaper-0-topic]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,696] INFO [ExpirationReaper-0-Heartbeat]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,698] INFO [ExpirationReaper-0-Rebalance]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-08-14 10:38:11,700] INFO Creating /controller (is it secure? false) (kafka.utils.ZKCheckedEphemeral)
[2017-08-14 10:38:11,732] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)
[2017-08-14 10:38:11,762] INFO [GroupCoordinator 0]: Starting up. (kafka.coordinator.group.GroupCoordinator)
[2017-08-14 10:38:11,764] INFO [GroupCoordinator 0]: Startup complete. (kafka.coordinator.group.GroupCoordinator)
[2017-08-14 10:38:11,767] INFO [Group Metadata Manager on Broker 0]: Removed 0 expired offsets in 4 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
[2017-08-14 10:38:11,894] INFO [ProducerId Manager 0]: Acquired new producerId block (brokerId:0,blockStartProducerId:0,blockEndProducerId:999) by writing to Zk with path version 1 (kafka.coordinator.transaction.ProducerIdManager)
[2017-08-14 10:38:11,990] INFO [Transaction Coordinator 0]: Starting up. (kafka.coordinator.transaction.TransactionCoordinator)
[2017-08-14 10:38:11,995] INFO [Transaction Marker Channel Manager 0]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)
[2017-08-14 10:38:11,995] INFO [Transaction Coordinator 0]: Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)
[2017-08-14 10:38:12,081] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2017-08-14 10:38:12,179] INFO Creating /brokers/ids/0 (is it secure? false) (kafka.utils.ZKCheckedEphemeral)
[2017-08-14 10:38:12,192] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)
[2017-08-14 10:38:12,194] INFO Registered broker 0 at path /brokers/ids/0 with addresses: EndPoint(arjun-VPCEH26EN,9092,ListenerName(PLAINTEXT),PLAINTEXT) (kafka.utils.ZkUtils)
[2017-08-14 10:38:12,195] WARN No meta.properties file under dir /tmp/kafka-logs/meta.properties (kafka.server.BrokerMetadataCheckpoint)
[2017-08-14 10:38:12,259] INFO Kafka version : 0.11.0.0 (org.apache.kafka.common.utils.AppInfoParser)
[2017-08-14 10:38:12,259] INFO Kafka commitId : cb8625948210849f (org.apache.kafka.common.utils.AppInfoParser)
[2017-08-14 10:38:12,261] INFO [Kafka Server 0], started (kafka.server.KafkaServer)
Troubleshoot Apache Kafka startup on Ubuntu
If Kafka does not start in the terminal, check these Ubuntu setup points before changing Kafka configuration files.
- Java is missing or too old: Run
java -versionand install a supported JDK for your Kafka version. - Wrong Kafka directory: Run Kafka commands from the extracted Kafka root directory where
binandconfigare present. - Storage not formatted in KRaft mode: Run
kafka-storage.sh formatbefore starting the broker for the first time. - Port 9092 is already in use: Stop the other local Kafka process or change the listener configuration in
config/server.properties. - Old ZooKeeper commands fail on a new Kafka release: Use the KRaft commands for current Kafka versions instead of starting ZooKeeper separately.
Editorial QA checklist for this Kafka Ubuntu tutorial
- Confirm that Java 17 or the required JDK version is installed before running current Kafka binaries.
- Check that the Kafka download file name in command examples matches the version selected from the Apache downloads page.
- Verify that KRaft commands are used for current Kafka releases and ZooKeeper commands are marked as older-version guidance.
- Test that the topic, console producer, and console consumer commands use the same topic name and
localhost:9092. - Keep terminal output examples separate from command examples so readers can copy only the commands they need.
Apache Kafka installation on Ubuntu FAQs
How do I install Apache Kafka locally on Ubuntu?
Install a supported Java JDK, download the Kafka binary package from the Apache Kafka downloads page, extract the .tgz file, format Kafka storage in KRaft mode, and start the broker with bin/kafka-server-start.sh config/server.properties.
How do I start Kafka in the Ubuntu terminal?
From the Kafka root directory, run bin/kafka-server-start.sh config/server.properties. For current Kafka releases, format the storage directory with bin/kafka-storage.sh format before starting the broker for the first time.
How do I get the Kafka version in Linux?
From the Kafka root directory, run bin/kafka-topics.sh --version. You can also check the extracted Kafka directory name or the broker startup logs, but the command-line version check is cleaner.
Is Apache Kafka free to install on Ubuntu?
Yes. Apache Kafka is an open-source project from the Apache Software Foundation. You can download and run Apache Kafka locally on Ubuntu without paying for Kafka software. Hosting, cloud services, support, or managed Kafka offerings may have separate costs.
Do I need ZooKeeper to install Apache Kafka on Ubuntu?
For current local Kafka setup, use KRaft mode and do not start ZooKeeper separately. ZooKeeper steps are mainly for older Kafka releases and older tutorials that were written before the KRaft-based startup flow became the default local quickstart path.
Apache Kafka Ubuntu installation summary
In this Apache Kafka Tutorial, we installed Java, downloaded Apache Kafka on Ubuntu, started Kafka using the current KRaft-based local setup, and verified the installation with a topic, producer, and consumer. The older ZooKeeper startup sequence is included for readers maintaining older Kafka releases.
TutorialKart.com