kafka-console-producer command not found
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
If your shell says kafka-console-producer is not found, the problem is usually not Kafka itself. It almost always means you are calling the wrong script name, running it from the wrong location, or your shell cannot see Kafka’s bin directory. Once you know how Kafka ships its CLI tools, the fix is usually quick.
Use the Correct Script Name
In current Kafka distributions, the console producer is typically invoked as a script inside the Kafka installation directory, not as a globally installed command.
On macOS and Linux:
On Windows:
If you type only kafka-console-producer, many systems will fail because that exact executable name is not on your PATH. The official Kafka quickstart uses bin/kafka-console-producer.sh, which is the safest form when you are inside the extracted Kafka directory.
Check Where Kafka Is Installed
First confirm that Kafka is actually present and that the script exists where you think it does.
If KAFKA_HOME is empty or the file does not exist, either Kafka is not installed, or your environment variable points to the wrong directory.
If you downloaded Kafka manually, a common layout looks like this:
In that case you can run the producer directly:
Using the full path is a good way to separate "Kafka is missing" from "my shell cannot find it."
Add Kafka to Your PATH
If you want to run Kafka commands from anywhere, add the bin directory to your shell PATH.
For zsh or bash:
After reloading your shell, verify it:
If that prints a path, your shell can now resolve the script.
On many systems it still will not resolve kafka-console-producer without the .sh suffix, so use the exact script name unless your package manager created an alias for you.
Make Sure You Are Using the Right Package
Some package-manager installs provide Kafka through wrappers, service packages, or container images, and the CLI tools may not land on your default PATH. For example, when Kafka runs inside Docker, the script exists inside the container, not on the host machine.
In that case, run the command inside the container:
That distinction matters. A healthy broker does not imply the host shell knows where the local CLI scripts live.
Verify the Command End to End
Once the script is found, do a minimal test:
If the command starts successfully but then fails with a broker or topic error, that is progress. It means the original command not found problem is solved and the next issue is network, broker startup, or topic configuration.
Common Pitfalls
The most common mistake is leaving off the .sh suffix on Unix-like systems. Kafka’s official scripts are usually named kafka-console-producer.sh, kafka-topics.sh, and so on.
Another common problem is confusing shell visibility with Kafka installation. You may have Kafka extracted somewhere, but if PATH does not include the bin directory, the shell still reports command not found.
Windows users often hit the reverse issue by copying Unix commands directly. On Windows, the script usually lives under bin\windows\ and uses the .bat extension.
Containerized environments also trip people up. If Kafka is running in Docker or Kubernetes, the CLI tool may only exist inside that runtime environment.
Finally, make sure the broker flag is current. Older examples use --broker-list; modern examples typically use --bootstrap-server. That will not cause command not found, but it often appears right after the first fix.
Summary
- The Kafka console producer is usually run as
bin/kafka-console-producer.sh, not plainkafka-console-producer. - Confirm the script exists under your Kafka installation directory.
- Add Kafka’s
bindirectory toPATHif you want to run the tool from anywhere. - Use the Windows
.batscript on Windows and the.shscript on Unix-like systems. - If Kafka runs inside a container, execute the CLI tool inside that container instead of on the host.
Related reading
- kafka-console-producer ignores value serializer?
- kafka-console-producer.sh TimeOutException
- Kafka consumer list
- Kafka-consumer. commitSync vs commitAsync
- Kafka-docker container scaling failed for wurstmeister with error as advertised listeners are already registered by broker 1001
- kafka-log4j-appender 0.9 does not work
- Kafka-ES-Sink ConnectException Key is used as document id and can not be null
- kafka-node LeaderNotAvailable errors on send

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.