# Connection refused at $BALENA\_SUPERVISOR\_ADDRESS

**URL:** <https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697>\
**Category:** balenaOS\
**Tags:** support\
**Created:** [October 15, 2021, 5:59pm UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697 "2021-10-15T17:59:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imolitor](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@imolitor](https://forums.balena.io/u/imolitor)\
**Post date:** [October 15, 2021, 5:59pm UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697/1 "2021-10-15T17:59:59Z")

</div>

Hi guys!

I’m using a private server in the cloud to run Balena OS.  
Fleet Raspberry Pi Zero W’s are running raspberrypi\_2.80.8\_rev1\_prod.img.

**All worked great until I had to change the Server’s password and with it the corresponding ca.crt certificate!**

`deploys` still run without any error and` pre-loading` works fine too.

However, the logs show errors around the $BALENA\_SUPERVISOR\_ADDRESS `curl patch`.

Here’s the code in `start.sh` which throws the error (it did work fine before). The `curl` throws the error.

```auto
# Change hostname
echo "yokoso" > /etc/hostname
hostname yokoso
hostnamectl set-hostname yokoso --static
curl -X PATCH --header "Content-Type:application/json" \**
    --data '{"network": {"hostname": "yokoso"}}' \**
    "$BALENA_SUPERVISOR_ADDRESS/v1/device/host-config? **
    apikey=$BALENA_SUPERVISOR_API_KEY"**

```

Here are the corresponding logs (with the **Connection refused** ):

```auto
[Logs] [10/15/2021, 10:31:14 AM] Rebooting
[Logs] [10/15/2021, 10:35:26 AM] Supervisor starting
[Logs] [10/15/2021, 10:33:27 AM] [yokoso] Systemd init system enabled.
[Logs] [10/15/2021, 10:33:28 AM] [yokoso] systemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
[Logs] [10/15/2021, 10:33:28 AM] [yokoso] Detected virtualization docker.
[Logs] [10/15/2021, 10:33:28 AM] [yokoso] Detected architecture arm.
[Logs] [10/15/2021, 10:33:28 AM] [yokoso] Set hostname to <yokoso>.
[Logs] [10/15/2021, 10:34:14 AM] [yokoso] curl: (7) Failed to connect to 127.0.0.1 port 48484: Connection refused

```

Any help is more than welcome!  
Thanks!

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [October 19, 2021, 2:01am UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697/2 "2021-10-19T02:01:47Z")

</div>

Hi @imolitor,

There are several possible causes for what may be wrong:

- Supervisor API has not started up at the time of running the `curl` command. This is possible, seeing as your logs list `Supervisor starting`(10:35:26 AM) as occurring after the curl (10:34:14 AM). I’m not sure if this is an error in the logs or just that system time hasn’t synced up yet.
- Invalid BALENA\_SUPERVISOR\_API\_KEY or BALENA\_SUPERVISOR\_ADDRESS.
- Something else, which we can begin to understand if you try running the curl with -v specified.

To check that the API key is valid, assuming you’re running a new enough Supervisor, run the following to see if the output of `echo $BALENA_SUPERVISOR_API_KEY` matches what the Supervisor has in its DB:

```auto
balena exec -it balena_supervisor node // This may be resin_supervisor depending on OS version, run balena ps to check
sqlite3 = require('sqlite3')
db = new sqlite3.Database('/data/database.sqlite')
db.all('select * from apiSecret',console.log)

```

BALENA\_SUPERVISOR\_API\_KEY should match the corresponding scoped entry for the service that you’re running `start.sh` from. If this is verified and doesn’t appear to be the issue, the problem could be one of the other ones listed above. I think in any case, pasting the output of `curl -v...` is a good place to start. Thanks!

Regards,  
Christina

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [October 19, 2021, 2:05am UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697/3 "2021-10-19T02:05:23Z")

</div>

Also, where are you running this start.sh script from? In a container? Does the container have the `io.balena.features.supervisor-api` label specified, per [docker-compose.yml fields - Balena Documentation](https://www.balena.io/docs/reference/supervisor/docker-compose/#labels)?

---

<div class="post-metadata">

**Author:** ![imolitor](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@imolitor](https://forums.balena.io/u/imolitor)\
**Post date:** [October 19, 2021, 3:04pm UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697/5 "2021-10-19T15:04:40Z")

</div>

Hi.  
Yes, the `docker-compose.yml` has the API label specified:

> services:  
> yokoso:  
> build: ./yokoso  
> network\_mode: host  
> privileged: true  
> restart: always  
> labels:  
> io.balena.features.dbus: ‘1’  
> io.balena.features.kernel-modules: ‘1’  
> io.balena.features.firmware: ‘1’  
> io.balena.features.supervisor-api: ‘1’  
> io.balena.features.balena-api: ‘1’

---

<div class="post-metadata">

**Author:** ![imolitor](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@imolitor](https://forums.balena.io/u/imolitor)\
**Post date:** [October 19, 2021, 3:06pm UTC](https://forums.balena.io/t/connection-refused-at-balena-supervisor-address/349697/6 "2021-10-19T15:06:03Z")

</div>

Thanks for this. I’ll have a look into it.

Strange is, that there were **no** changes to any of the code. Just the server password and with it the `ca.crt` **certificate** changed.
