If you’re running Kafka in Docker (or similar) you need to configure the listeners correctly. This article describes it in detail.
Here’s an example of a Docker Compose that you can use to access Kafka from your host machine.
Disclaimer: I wrote the article 🙂