kafka java.net.ConnectException: Connection timed out: no further information

Open source software supply chain lighting plan, waiting for you>>>

The problem is that there is no problem testing locally

1. View topice

./bin/kafka-topics.sh -list -zookeeper localhost:2181

No problem

2、

./bin/kafka-console-producer.sh –broker-list localhost:9092 –topic liuda

3,、

./bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic liuda –from-beginning

there is no problem in these steps

But when testing with java code, it always reports an error: the link is not available

java.net.ConnectException: Connection timed out: no further information

1. The firewall is off, no problem

2. In the configuration file server. Properties

# listeners=PLAINTEXT://0.0.0.0:9092
#advertised.listeners=PLAINTEXT://120.78.22.22:9092

What we need to pay attention to here is

Both are disabled

Still not

Baidu checked the original when using the producer and consumer client of Kafka, it can’t use localhost, but must specify the local domain name clearly

In server.properties, add the following configuration:

Host. Name = 192.168.111.130 # local IP address

So that the project can be happily connected

Similar Posts: