'-bash: kafka-server-start.sh: command not found

After I installed kafka through homebrew, and my current version is 0.9.0.1.

I was following the steps in this post. At step 3, when I run following command in terminal

kafka-server-start.sh /usr/local/etc/kafka/server.properties

I got: -bash: kafka-server-start.sh: command not found

And I tried to solve this and search for solution for this online and anywhere. But I could not find any.

Does anyone know how to fix this?



Solution 1:[1]

You probably need to put a ./ in front of your command. Like this:

./kafka-server-start.sh /usr/local/etc/kafka/server.properties

This of course you are currently in the $KAFKA_HOME/bin directory. Alternatively, you could try:

export KAFKA_HOME=/path/to/kafka/install/directory
$KAFKA_HOME/bin/kafka-server-start.sh /usr/local/etc/kafka/server.properties

Or you could do:

export PATH=$KAFKA_HOME/bin:$PATH

And then run your original command without the ./

Solution 2:[2]

I faced the same problem on mac but below command worked well

kafka-topics  --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic myTopic

Solution 3:[3]

Please Follow the below steps and it should work as I faced the exact issue

to find the JAVA exact path below is the command

ls -l /etc/alternatives/java

lrwxrwxrwx 1 root root 31 Jun  8 01:15 /etc/alternatives/java -> /opt/java/jdk1.8.0_202/bin/java

Set the java home

export JAVA_HOME=/opt/java/jdk1.8.0_202/bin/java
export PATH=$PATH:/opt/java/jdk1.8.0_202/bin/java

set the Kafka path as below

nano .bashrc
export PATH=/home/biraj/kafka_2.12-2.2.1/bin:$PATH

Now the kafka-server-start.sh should work

Solution 4:[4]

Go to kafka_2.12-2.3.1/bin folder.

cd kafka_2.12-2.3.1/bin

Then enter this command.

export PATH=$KAFKA_HOME/bin:$PATH

Thats it! Now Execute kafka-server-start.

Solution 5:[5]

As per the link mentioned In step 3 don't go to the address mentioned i.e :

/usr/local/Cellar/kafka/0.9.0.1/bin/

Instead, go to the following path :

/usr/local/Cellar/kafka/0.9.0.1/libexec/bin/

and enter the command with ./ added if path is not set.

kafka-server-start.sh /usr/local/etc/kafka/server.properties

OR

./kafka-server-start.sh /usr/local/etc/kafka/server.properties

I Tested this on version 0.11.0.1. Just check your version. Also you should have kafka-server-start.sh file in the mentioned path.

Then you can execute that command. just try with or without ./

Solution 6:[6]

Make sure that java installed in your ubuntu, then just put './' as @davidgriffin said.

./kafka-server-start.sh /usr/local/etc/kafka/server.properties

Solution 7:[7]

Add kafka folder to your C:\ drive where java is also installed. It worked for me

Solution 8:[8]

Are you in the right folder? I had the same issue when I was in the bin folder without realising it. you have to be at the root folder of kafka.

See: https://www.sohamkamani.com/blog/2017/11/22/how-to-install-and-run-kafka/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Griffin
Solution 2 Rahul Garg
Solution 3 BigData-Guru
Solution 4 Kiran Sk
Solution 5
Solution 6 Ozer Batu Karg?l?
Solution 7 Mohammed Harfan
Solution 8 Tee Hui Tan