Lunary was designed to be surprisingly simple to self-host, through a Docker image which include the frontend, the api and workers.



Set up a PostgreSQL database

Set up a PostgreSQL database to store your Lunary data (version 15 or higher).


Log in to the private Docker Repository

Make sure Docker is installed on your host machine before running the following command:

docker login -u lunarycustomer

Then, paste your organization's access token, which will be provided by Lunary when your subscription is activated.


Run the Docker image

Run the following command to start the Lunary Docker image:

docker run -d \
-e DATABASE_URL="postgresql://<username>:<password>@<host>:<port>/<dbname>?sslmode=require" \
-e API_URL="http://<your-host-ip>:3333" \ # or replace with a domain name
-e APP_URL="http://<your-host-ip>:8080" \ # or replace with a domain name
-e JWT_SECRET="<jwt_secret>" \ # You can generate a random string using `openssl rand -base64 32`
-e LICENSE_KEY="<your_license_key>" \
-p "8080:8080" \ # Frontend
-p "3333:3333" \ # API port
lunary/lunary-ee:<release_version> # versions are available here:

Configure optional environment variables

The following environment variables are optional and can be used to enable the playground, evaluation and radar features:

# Or if using Azure OpenAI:

🎉 Done!

You're all set! Open http://your-host-ip-or-url:8080 to access the app.
Make sure to export the environment variable LUNARY_API_URL=http://your-host-ip-or-url:3333 when using the SDK to send the queries to your server.


Requested access to the resource is denied.

You need to log in to the private Docker repository before running the image.

Make sure you have the correct access token and that you are logged in.

Error: connect ECONNREFUSED

If you are running the database on the same machine, you can use -network=host when running the Docker image.

docker run
-e DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/lunary?sslmode=require" \
--network=host \
-e API_URL="" \
-e JWT_SECRET="replace_with_your_secret_string" \
-p "8080:8080" \
-p "3333:3333" lunary/lunary-ee:latest

Error: Client network socket disconnected before secure TLS connection was established

This means the database's SSL certificate is not properly set. Either fix the SSL certificate or disable SSL by removing ?sslmode=require from the DATABASE_URL environment variable (not recommended if the database is exposed to the internet).

Questions? We're here to help.