TTN (http integration) to private server

Hi, I am trying to send data from TTN to my own server, and then save the data on my MySQL database. I’m fairly new at Python, and with HTTP, so for me there are some challenges.

What i’ve done so far:


Created http integration which looks like this:

Status: Running


[IP-ADDRESS] --> is the ip address of our server -

SERVER (Python)

Created file, which looks like this:

import time
import ttn

app_id = "xxx"
access_key = "ttn-account-v2.x-xxx"

def uplink_callback(msg, client):
print("Received uplink from ", msg.dev_id)
handler = ttn.HandlerClient(app_id, access_key)

# using mqtt client
mqtt_client =

# using application manager client
app_client = handler.application()
my_app = app_client.get()
my_devices = app_client.devices()

When running the code above with this command:

sudo python

I receive this error:

  Traceback (most recent call last):
  File "", line 22, in <module>
    my_app = app_client.get()
  File "/home/xxx/.local/lib/python2.7/site-packages/ttn/", line 64, in get
    " application: {}".format(err.code().name))
  RuntimeError: ('Error while getting the', ' application: PERMISSION_DENIED')

Why do I receive this error - permission denied? What am I doing wrong? Whenever this is fixed I can create code for inserting this data into the SQL database, but first of all I need this to work.

Hi @DTUIotLab, you appear to be mixing up the TTN HTTP and MQTT integrations.
Your TTN application integration is trying to post the uplink data using HTTP.
Your server-side code is trying to listen to the MQTT publish/subscribe system.
These are completely separate protocols for integration.

MQTT integration is enabled by default so if your python code is correct then this will work without any HTTP integration on the TTN servers.

I suggest that you start by following the TTN Quick Start at

Get MQTT up and running using the quick start and then start to work on using python.


maybe this helps a bit

1 Like

Thanks, @cultsdotelecomatgmai & @BoRRoZ

I thought HTTP integration was the best solution to send data from TTN to my own server. For some reason, this code, for me, seemed to be one of the steps to do so.

I know of --> - but it makes no sense to me.

I will look into MQTT. Thanks both for responding!

I will try with node-red

Your code is not for HTTP integration :wink: