Deploy TeslaMate
Data logger for Tesla cars, with Grafana dashboards
teslamate-proxy
Just deployed
Just deployed
/var/lib/postgresql/data
grafana
Just deployed
/var/lib/grafana
mosquitto
Just deployed
/mosquitto/data
teslamate
Just deployed
/opt/app/import
Deploy and Host TeslaMate on Railway
TeslaMate is an open source data logger for Tesla vehicles. It polls the Tesla API for your car, records every drive, charge, software update and sleep period into PostgreSQL, and turns that history into Grafana dashboards covering efficiency, battery degradation, charging cost and vampire drain. Owners use it to prove range loss under warranty, split home and public charging costs, and own their data rather than rent it.
Self-host TeslaMate on Railway and what normally takes an evening of Docker Compose is already wired together: teslamate runs the app, Postgres stores the history, grafana serves the bundled dashboards against that database, mosquitto publishes live vehicle state over MQTT, and teslamate-proxy puts a password in front of the web interface. That last piece matters — TeslaMate has no login of its own, so running it without a gateway would leave your car's location on the open internet.

Getting Started with TeslaMate on Railway
Deploy the template, then open the public URL of the teslamate-proxy service. The browser asks for a username and password — the PROXY_USERNAME and PROXY_PASSWORD values on that service, not your Tesla credentials. Behind it is TeslaMate's sign-in page, which wants a Tesla API access token and refresh token. TeslaMate never sees your Tesla password: generate the pair with a token app such as tesla_auth, then paste both in. The vehicle appears within a minute and logging starts the next time you drive.
Open Settings next and check the two URL fields, which link TeslaMate and Grafana in both directions; change them only for a custom domain. Then open the grafana service's own URL and sign in with GF_SECURITY_ADMIN_USER and GF_SECURITY_ADMIN_PASSWORD. Twenty-three dashboards are already provisioned — start with Overview, and use Database Information to confirm the datasource works before any driving data exists. Finally add geo-fences for home and work, so charges and trips are labelled by place rather than coordinates.

About Hosting TeslaMate
TeslaMate is an Elixir application that adapts its polling rate to what the car is doing — seconds apart while driving or charging, nothing once the car sleeps, so it adds no measurable vampire drain. Everything it records is yours, in your own database, with no retention limit.
- High-resolution drive and charge logging, with GPS traces and per-session energy
- Battery health and projected-range tracking over the life of the car
- Charging cost tracking, with per-geo-fence pricing rules
- Geo-fencing, so home, work and favourite superchargers are named rather than plotted
- MQTT publishing for Home Assistant, Node-RED and other automation tools
- Import from TeslaFi and tesla-apiscraper
TeslaMate writes to Postgres over Railway's private network, Grafana reads that same database and never talks to the app, and the gateway terminates the password prompt so only authenticated traffic reaches the app.
Why Deploy TeslaMate on Railway
A logger that must never miss a drive is what a managed platform is for.
- Always-on hosting without a Raspberry Pi that dies mid-road-trip
- Managed PostgreSQL with backups, not a database on an SD card
- Private networking between app, database and broker out of the box
- HTTPS, a public hostname and a password gate from the first deploy
Common Use Cases
- Warranty and resale evidence — a year of battery-degradation data beats a dashboard estimate when arguing range loss.
- Charging cost accounting — a per-kWh rate on a home geo-fence and another for public chargers gives a real cost per mile.
- Business mileage logs — export drives for expense claims, addresses resolved automatically.
- Home automation — trigger the garage or a charge schedule from live car state over MQTT.
Dependencies for TeslaMate
teslamate/teslamate:latest— the app and web interface, from teslamate-org/teslamateghcr.io/railwayapp-templates/postgres-ssl:18— holds every drive, charge and position. The migrations need thecubeandearthdistanceextensions, both on this image.teslamate/grafana:latest— Grafana 13 with the dashboards and Postgres datasource already provisionedeclipse-mosquitto:2— the MQTT broker, built with a password file and a TLS listenercaddy:2-alpine— the authentication gateway in front of the app
Environment Variables Reference
| Variable | Description | Required |
|---|---|---|
ENCRYPTION_KEY | Encrypts stored Tesla tokens; changing it invalidates them | Yes |
SECRET_KEY_BASE | Session signing key, must stay stable across deploys | Yes |
PROXY_PASSWORD | Password for the web interface, checked by the gateway | Yes |
PROXY_USERNAME | Username for that prompt, admin by default | No |
GF_SECURITY_ADMIN_PASSWORD | Grafana admin password | Yes |
MQTT_PASSWORD | Broker password, shared with any external subscriber | Yes |
TZ | Local time zone, e.g. Europe/Berlin | No |
DISABLE_MQTT | Set true to drop the broker entirely | No |
Deployment Dependencies
- Source: teslamate-org/teslamate, AGPL-3.0; images teslamate/teslamate and teslamate/grafana
- Documentation: docs.teslamate.org. Sign-in needs a Tesla API access and refresh token pair, generated with a token app.
Hardware Requirements for Self-Hosting TeslaMate
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU |
| RAM | 1 GB across all services | 2 GB |
| Storage | 5 GB for Postgres | 10 GB after a few years of driving |
| Runtime | Erlang/OTP 29, PostgreSQL 17+ | from the images |
The app idles at roughly 300 MB; storage is what grows, at a few megabytes per thousand miles.
Self-Hosting TeslaMate
Outside Railway TeslaMate is a Docker Compose stack. The minimum is the app and a database:
docker run -d --name teslamate -p 4000:4000 \
-e ENCRYPTION_KEY=change-me -e DISABLE_MQTT=true \
-e DATABASE_HOST=database -e DATABASE_NAME=teslamate \
-e DATABASE_USER=teslamate -e DATABASE_PASS=change-me \
teslamate/teslamate:latest
Add Grafana and the broker for the full experience:
services:
database:
image: postgres:18-trixie
environment: [POSTGRES_USER=teslamate, POSTGRES_PASSWORD=change-me, POSTGRES_DB=teslamate]
volumes: ["teslamate-db:/var/lib/postgresql"]
grafana:
image: teslamate/grafana:latest
environment: [DATABASE_USER=teslamate, DATABASE_PASS=change-me, DATABASE_HOST=database]
ports: ["3000:3000"]
mosquitto:
image: eclipse-mosquitto:2
Upstream is explicit that this belongs on a home network: exposed to the internet it has no authentication at all, which is why the password gateway is part of this template rather than an optional extra.
How Much Does TeslaMate Cost to Self-Host?
TeslaMate is free and open source under AGPL-3.0, with no paid tier, no account and no telemetry. On Railway you pay only for the infrastructure the five services use, which for a single vehicle is a small always-on workload. The alternatives are subscriptions with usage caps — TeslaFi around $8 a month, Tessie and Teslascope comparable — and none let you keep the raw data. Pick TeslaMate for unlimited history you own, a hosted service if you would rather have a phone app than a database.
FAQ
What is TeslaMate? An open source, self-hosted data logger for Tesla vehicles. It records drives, charges, battery health and sleep behaviour into PostgreSQL and visualises them in Grafana.
What does this Railway template deploy? Five services: TeslaMate, a managed PostgreSQL database, Grafana with the bundled dashboards, an MQTT broker, and a Caddy gateway that password-protects the web interface.
Why does the template include a password gateway? TeslaMate ships no authentication — every page including Settings is open to whoever loads it, and those pages show your car's location. Upstream's own hardening guide answers this with a reverse proxy doing HTTP Basic Auth, and so does this template.
Do I need to give TeslaMate my Tesla password?
No. You generate an access and refresh token pair with a separate token app and paste those in. They are encrypted at rest with your ENCRYPTION_KEY.
Why is PostgreSQL a separate service instead of SQLite?
TeslaMate is built around PostgreSQL and needs the cube and earthdistance extensions for distance queries. Grafana reads that same database directly, which removes any export step.
Can I connect TeslaMate to Home Assistant?
Yes. The broker is reachable over TLS from outside Railway: point Home Assistant's MQTT integration at its public host and port with the credentials the app uses, and set MQTT_HOME_ASSISTANT_DISCOVERY=true. Vehicles polled by one deployment all publish there, so a multi-car Tesla account needs no second instance.
Template Content
teslamate-proxy
gridalpha/teslamate-railwaygrafana
teslamate/grafana:latestmosquitto
gridalpha/teslamate-railwayteslamate
teslamate/teslamate:latest