Add a custom domain
Serve an app under your own domain, with HTTPS.
Every public app has an address under lilylabs.app. This guide adds your own domain to an app, for example shop.example.com. Domains explains the states a domain passes through.
Before you start
- A deployed, public app. The examples use the app
copperfox. - Access to the DNS settings of your domain.
- A subdomain such as
shop.example.comorwww.example.com. A bare domain such asexample.comonly works if your DNS provider supportsALIASrecords or CNAME flattening.
Steps
Add the domain to the app
- Open the app and select the Domains tab.
- Select Add domain and enter the name, for example
shop.example.com. - The domain opens a setup with four phases: Domain, DNS records, Certificate and Live. It lists the two DNS records with Host and Value. Copy both.
lly domain copperfox add shop.example.comThe command prints the two DNS records to create:
DNS records
Type Name Value Purpose
CNAME shop.example.com copperfox.lilylabs.app routing
TXT _lily-verify.shop.example.com lily-verify=dv_1 verificationCreate the two DNS records
In the DNS settings of your domain, create both records exactly as printed. The CNAME record routes traffic to the app. The TXT record proves that the domain is yours.
Wait for verification
LILY checks pending domains every 30 seconds. DNS changes can take a few minutes to become visible.
Select Check in the setup. Each record shows Found, Missing or Wrong value. Once ownership is confirmed, the certificate is issued, which usually takes a few minutes.
lly domain copperfox check shop.example.comTo wait in the terminal until the domain is verified, for up to 10 minutes:
lly domain copperfox add shop.example.com --waitCheck that it worked
The domain moves from Pending to Verified and then to Active. Once it is Active, https://shop.example.com opens your app with a valid certificate.
Hostname Kind State Since
copperfox.lilylabs.app slug active 2d ago
shop.example.com custom active 1m agoIf it does not work
| What you see | Cause | Fix |
|---|---|---|
| The domain stays Pending | The TXT record is missing, has a typo or is not visible yet | Compare the record with the output of lly domain copperfox check shop.example.com and wait a few minutes. See The domain stays pending. |
lly domain add exits with code 5 | The hostname is already assigned to another app | Remove it from the other app first |
--wait exits with code 6 | The domain was not verified within 10 minutes | Check the records, then run lly domain copperfox check shop.example.com |
Your DNS provider rejects the CNAME | The domain is a bare domain such as example.com | Use a subdomain, or an ALIAS record if your provider offers one |
| The setup says the app is private | A private app cannot be reached by a domain, so only the TXT record is checked | Make the app public. See Expose a port |
A wildcard such as *.example.com is rejected | Wildcards are not supported | Add each hostname separately |
More messages and their fixes: Troubleshooting.
Use an agent
Add the custom domain shop.example.com to my LILY app "copperfox".
Run `lly domain copperfox add shop.example.com` and show me the two DNS records it prints.
Do not change DNS yourself. After I confirm the records exist, run
`lly domain copperfox check shop.example.com` until the state is active, then tell me.