question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I can't connect to Kafka in OS X

See original GitHub issue

Hi.

I’d been having problems launching Kafka (more about this in this recent thread: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/confluent-platform/DRd_XfeW0C8).

Now, I launched Kafka, however, I can’t connect it:

# the kafka container uses this port
$ telnet localhost 29092
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

PS: I’m trying this docker-compose.yml.

This is my altered docker-compose.yml file:

I tried to expose the ports, however, I think, in network host mode, it can’t be done.

---
version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:latest
    network_mode: host
    environment:
      ZOOKEEPER_CLIENT_PORT: 32181
      ZOOKEEPER_TICK_TIME: 2000
    extra_hosts:
      - "moby:127.0.0.1"

  kafka:
    image: confluentinc/cp-kafka:latest
    network_mode: host
    ports:
      - "29092:29092"
    depends_on:
      - zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: localhost:32181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092
    extra_hosts:
      - "moby:127.0.0.1"

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

24reactions
tmendenhallcommented, Jul 11, 2017

I was able to have some success on macOS (docker community version) using the following compose file:

---
version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:3.2.1
    ports:
     - 32181:32181
    environment:
      ZOOKEEPER_CLIENT_PORT: 32181
      ZOOKEEPER_TICK_TIME: 2000
    extra_hosts:
      - "moby:127.0.0.1"
      - "localhost: 127.0.0.1"

  kafka:
    image: confluentinc/cp-kafka:3.2.1
    ports:
     - 29092:29092
    depends_on:
      - zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:32181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
      KAFKA_DELETE_TOPIC_ENABLE: "true"
    extra_hosts:
      - "moby:127.0.0.1"
      - "localhost: 127.0.0.1"

Which allows kafka to connect to the zookeeper instance using the bridge network but both remain accessible to a Java application running on my development machine at localhost and the exposed correct port. I hope this proves useful.

Note: I am not using the most recent version of the cp-zookeeper and cp-kafka docker images.

12reactions
inancgumuscommented, May 12, 2017

Probably, noone is looking at these issues…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Can't I Connect to Kafka? | Troubleshoot Connectivity
When a client wants to send or receive a message from Apache Kafka ®, there are two types of connection that must succeed:...
Read more >
Cannot run Kafka on mac - Stack Overflow
1 Answer 1 · Shutdown both Kafka and Zookeeper · If required, take backup of the existing logs of Kafka and Zookeeper ·...
Read more >
Can't connect to Kafka on Apple Silicon · Issue #647 - GitHub
Hello. When i am trying to run kafka on apple with silicon m1 chip, i have no errors on logs, but can't connect...
Read more >
How to Install Kafka on Mac? | 3 Easy Steps - Hevo Data
This article provides you with a step-by-step guide to easily Install Kafka on Mac Manually as well as via Homebrew commands.
Read more >
Apache Kafka Installation on Mac using Homebrew - Medium
WARNING: During server start, you might be facing connection broken issue. ... To fix this issue, we need to change the server.properties file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found