modifying hosts file on Balena OS

Is it possible to modify the hosts file through Balena Cloud with the “variables” tab?

There is a problem with spotify’s API in Denmark that gives the error:
librespot_core::channel] channel error: 2 1

I read on this thread that if you modify the hosts file that it would connect to the right server instead.

So therefore i’d like to add the following string:

If this is not availble on Balena Cloud, what partition and folder would i find the hosts file to modify.

1 Like

Another solution what would be better practice would be to add “–ap-port=12321” as a startup flag for librespot.
I see that this can be done in Balena Cloud under variables what “Name” sould be added to have this as a flag for librespot?


Is it possible to modify the hosts file through Balena Cloud with the “variables” tab?

Probably. I will assume you aren’t looking to change the hosts file for balenaOS instead you are looking to change the hosts file of your container running your app that uses the Spotify API. If my assumption is correct, then you will find the hosts file most probably in /etc/hosts inside the service.

Is there a specific reason why you intend to configure this using variables in balenaCloud other than being able to change this whenever you want. From what I see, I feel this would be a one time change but feel free to correct me on that. If this is indeed a one time change then I would recommend making this change at build-time of your image which will make sure this change persists through restarts. Let me know if this would help to solve your issue.

1 Like

Hi @micaslarsen

I just added extra_hosts to my docker-compose.yml with success:

    build: .
    privileged: true
    restart: always
    network_mode: host
      source :

pushed to the fleet and now my application can resolve the hostname source to the right ip.

We are using this for our etcherPro so that we can enter something like this: