openBalena Internal Server Error on device registration with Python SDK


I am hoping to use the Balena Python SDK to pre-register my devices so that I can set critical environment variables at the same time the SD card is flashed.

However, when my python script executes balena.models.device.register(<my_application_name>, <32_character_UUID>)

I receive an internal server error.

Here is my balena.cfg file (I am running openBalena 2, not 3 yet):

pine_endpoint = https://api.<my_domain>/v5/
api_endpoint = https://api.<my_domain>/
builder_url =
api_version = v5
device_actions_endpoint_version = v1
data_directory = C:\Users\Caleb\.balena
image_cache_time = 604800000
token_refresh_interval = 3600000
timeout = 30000
cache_directory = C:\Users\Caleb\.balena\cache
token = <my_token>

Any ideas?

Hi Caleb, check out the logs for the API service and see if you can find the exception. That can help us diagnose.

The Python API? How?

Hi Caleb,

We actually meant the logs printed by the open-balena-api container that’s running on your server.
Let me point you to the template part of the respective docker-compose service:

Once you get a terminal session to the open-balena server, you should be able to do a docker ps to grab the API container name and just use journalctl -f -n 100 -u <CONTAINER_NAME> to start seeing the emitted logs.

Kind regards,

I have attached my logs from the docker ps (docker-ps.log) and journalctl -f -n 100 -u openbalena_api_1 (journalctl-api.log). Since the journalctl didn’t show any logs, I also tried without the -u flag and have attached that output (journalctl.log)

Any ideas as to why the journalctl command you gave didn’t show anything? Do I need to log in as a particular user? I did make sure to test out the code which produces the error while the journalctl was running.

docker-ps.log (2.1 KB) journalctl-api.log (49 Bytes) journalctl.log (11.2 KB)

Hey there it seems there were no logs from that service?

can you try to get the logs directly while trying to run the test code again using docker logs --follow <container ID>?

in your case that would docker logs --follow 291fa7767aac