Installing Thingsboard in your own server
How to install Thingsboard on your own server running on Ubuntu 20.04
The original content was accessed on 7th July 2025 from https://thingsboard.io/docs/user-guide/install/ubuntu/
Have a fresh Ubuntu 20.04 installation ready, recommended is to have a 4GB machine, but 1GB also tested but extremely slow in loading.
First things first.
SSH login as root first, and create a sudo user,
adduser <user>usermod -aG sudo <user>
For security reasons, disable root ssh login and change port in the following file,
nano /etc/ssh/sshd_config
Change the values,
Port <any unused between 1024 and 65535>PermitRootLogin no
Save, exit and restart the service,
sudo service ssh restart
For good measure exit from ssh and re-login using new port and sudo user.
Installing the system.
Install Java 17,
sudo apt update && sudo apt install openjdk-17-jdk-headless -y
Check Java version,
java -version
Get Thingsboard,
wget https://github.com/thingsboard/thingsboard/releases/download/v4.1/thingsboard-4.1.deb
Install it, (as a service)
sudo dpkg -i thingsboard-4.1.deb
Install gnupg ,
sudo apt-get install -y gnupg2 gnupg gnupg1
Install Postgres dependency,
sudo apt install -y postgresql-commonsudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
Install and launch the postgresql service,
sudo apt updatesudo apt -y install postgresql-16
If during this process, NO_PUBKEY error comes up, (Your key will be shown in the terminal), add the key and rerun installation.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <your key>
Then start the Postgres service,
sudo service postgresql start
Then, secure Postgres with a password, (use Alphanumeric only)
sudo -u postgres psql -c "\password"
Lets connect to the Database,
psql -U postgres -d postgres -h 127.0.0.1 -W
Postgress prompt should appear.
In it, create the database for Thingsboard
CREATE DATABASE thingsboard;
Then type and execute,
EXIT;
to exit.
Now Thingsboard configuration,
sudo nano /etc/thingsboard/conf/thingsboard.conf
Copy and paste below to end of file, (better get it from original source)
# DB Configuration export DATABASE_TS_TYPE=sqlexport SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboardexport SPRING_DATASOURCE_USERNAME=postgresexport SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE# Specify partitioning size for timestamp key-value storage. Allowed values: DAYS, MONTHS, YEARS, INDEFINITE.export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS
Since I'm using a 1GB machine, I'm adding that to the end of configuration,
export JAVA_OPTS="$JAVA_OPTS -Xms2G -Xmx2G"
Save and exit.
I'm also loading the demo data
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
And lastly, start the Thingsboard service,
sudo service thingsboard start
Once the system is running you can access it at,
http://localhost:8080/orhttp://<server_IP>:8080/orhtt?//<your_domain_name>
nginx Web server to handle requests.
This is a precursor to enabling SSL in the future
This is useful if you have a domain name. This will allow us to access the server on port 80. then your URL becomes <your_domain_name>, no need to enter port 8080
Install nginx,
sudo apt-get install nginx
Test nginx working by,
http://<your_domain_name>
on your browser or
sudo service nginx status
on the terminal.
Assuming we have only one server, lets load a configuration file to serve Thingsboard via nginx, first create file and open for editing,
sudo nano /etc/nginx/conf.d/<filename>.conf (tbproxy.conf)
Add the following server block to the file,
server {listen 80;server_name <domain_name>;location / {proxy_pass http://<LOCAL_THINGSGBOARD_IP_OR_DOMAN>:8080;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";proxy_set_header Host $host;}}
After saving and exiting the text editor, run,
sudo systemctl reload nginx
This will restart the nginx reloading all configurations.
You should be able to access the server with your domain name.