I have a nodejs app containerized as a linux container which uses the kafka-node library.

Kafka runs on the host machine which runs windows with:

* Zookeeper port : 2181
* Kafka broker port : 9092

I run the the nodejs container with the following command:

```
docker container run  --network host --name nm name:1.0

```

In order to connect with the host's kafka I am using the following command: 

```
client = new kafka.KafkaClient({kafkaHost: "localhost:9092"});

```

But this throws :

```
Error: connect ECONNREFUSED 127.0.0.1:9092
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1126:14) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9092
}

```

When I change the connect command to :

```
client = new kafka.KafkaClient({kafkaHost: "host.docker.internal:9092"});

```

I am getting : 

```
TimeoutError: Request timed out after 30000ms
    at new TimeoutError (/usr/src/app/node_modules/kafka-node/lib/errors/TimeoutError.js:6:9)
    at Timeout._onTimeout (/usr/src/app/node_modules/kafka-node/lib/kafkaClient.js:491:14)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {
  message: 'Request timed out after 30000ms'
}

```

Can someone advise what I am doing wrong ?

**UPDATE**

When switching to a linux host machine, the above localhost methodology runs just fine .