# Problem running Kafka Distributed as a service

**URL:** <https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445>\
**Category:** Kafka Connect\
**Created:** [11 April 2021 12:34 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445 "2021-04-11T12:34:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvaneynd](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@rvaneynd](https://forum.confluent.io/u/rvaneynd)\
**Post date:** [11 April 2021 12:34 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/1 "2021-04-11T12:34:35Z")

</div>

We use Confluent Cloud with and external VM to run our 3rd party connectors.  
Starting the connect-distributed from the command line is no problem. But when I try to set it up as service using confluent-kafka-connect.service

[Unit]  
Description=Apache Kafka Connect - distributed  
Documentation=[http://docs.confluent.io/](http://docs.confluent.io/)  
After=network.target

[Service]  
Type=simple  
User=AdminUser  
Group=confluent  
ExecStart=/usr/bin/connect-distributed /etc/kafka/kafka-connect-distributed.properties  
TimeoutStopSec=180  
Restart=no

[Install]  
WantedBy=multi-user.target

I see the following error in journalctl

WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient:796)

I have no idea why this error appears.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [12 April 2021 11:37 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/2 "2021-04-12T11:37:39Z")

</div>

seems as your distributed connect cluser tries to connect to localhost.

my understanding is that your brokers are in confluent cloud?

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [12 April 2021 12:49 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/3 "2021-04-12T12:49:45Z")

</div>

Yes, if you’re using Confluent Cloud you need to amend `/etc/kafka/kafka-connect-distributed.properties` to include the correct broker details per [the documentation](https://docs.confluent.io/cloud/current/cp-component/connect-cloud-config.html).

---

<div class="post-metadata">

**Author:** ![rvaneynd](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@rvaneynd](https://forum.confluent.io/u/rvaneynd)\
**Post date:** [12 April 2021 13:15 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/4 "2021-04-12T13:15:34Z")

</div>

Robin,

Yes, we use Confluent Cloud with on-prem Workers due to the fact that we use 3rd party connectors.

That is what I have been using and it works when I start it from the command line  
(e.g. ./bin/connect-distributed ./etc/my-connect-distributed.properties).  
The only difference is that I commented out the consumer. section as these VM’s only run producer connectors.

So it works from the command line but not when trying to use it as a service.

Raoul

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [12 April 2021 13:22 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/5 "2021-04-12T13:22:16Z")

</div>

I would re-enable the consumer section.  
Kafka Connect is also a consumer from the internal topics that it uses to store and fetch connector configuration, offsets, status, etc.

---

<div class="post-metadata">

**Author:** ![rvaneynd](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@rvaneynd](https://forum.confluent.io/u/rvaneynd)\
**Post date:** [12 April 2021 14:19 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/6 "2021-04-12T14:19:44Z")

</div>

Robin,

I have made that change and also double checked the permissions on the properties file. But no luck. Still the same error when trying to start the confluent-Kafka-connect service.  
And again, running it from the command line, no problem.

Raoul

---

<div class="post-metadata">

**Author:** ![rvaneynd](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@rvaneynd](https://forum.confluent.io/u/rvaneynd)\
**Post date:** [12 April 2021 14:34 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/7 "2021-04-12T14:34:43Z")

</div>

All,

Well I think I found a work around. The problem was that if you run it from the command line the process will stop when you close the connection to the VM (Linux machine).  
But when you start /bin/connect-distributed without any parameters, it comes back with:  
USAGE: /usr/bin/connect-distributed [-daemon] connect-distributed.properties

So I tried to include the command -daemon and this seems to work to push the worker to the background and am able to close the terminal window without halting the process.

Might be worth to include this in the documentation as the -daemon parameter is nowhere discussed.

Thank you again for trying to help and the quick responses. Really appreciate it.

Raoul.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [19 April 2021 14:35 UTC](https://forum.confluent.io/t/problem-running-kafka-distributed-as-a-service/1445/8 "2021-04-19T14:35:28Z")

</div>

Closed on 19 April 2021 14:35 UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
