I've been trying to consume messages from broker using kcat, however for some reasons kcat tries to connect to localhost:9092 instead of the broker I've supplied to it using the -b switch. I've been through all the official documentation and several how-to's but i can not figure this one out.
An example :
kcat -C -b <remote kafka broker ip> -t test-topic1 -o -1 -e
%3|1675853772.320|FAIL|rdkafka#consumer-1| [thrd:localhost:9092/1001]: localhost:9092/1001: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT)
% ERROR: Local: Broker transport failure: localhost:9092/1001: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT)
%3|1675853772.576|FAIL|rdkafka#consumer-1| [thrd:localhost:9092/1001]: localhost:9092/1001: Connect to ipv6#[::1]:9092 failed: Connection refused (after 0ms in state CONNECT)
% ERROR: Local: Broker transport failure: localhost:9092/1001: Connect to ipv6#[::1]:9092 failed: Connection refused (after 0ms in state CONNECT)
I think i'm missing something obvious here, but why does it want to connect to localhost? If i issue a command like
kcat -b <remote kafka broker ip> -L
it works like a charm and lists topics and partitions from the <remote kafka broker ip> broker
Have you double-checked your kcat configuration? It might be reading from that if you're not providing your broker explicitly.
Here's a blog post on how to set up your config. If you set it up that way, you don't have to pass in your -b
flag every time you run it, either.