---
title: "Add a custom domain to your app | Pethost Docs"
description: "Point a domain you own at your app with one CNAME record, or an ALIAS at the root, or use a name under your Pethost domain. HTTPS comes by itself."
---

[Docs](https://pethost.dev/docs/) · Domains

# Add a custom domain to your app

Updated 29 October 2026 · 8 min read

To add a custom domain to your app on Pethost, you make one DNS record, a CNAME from the name to your machine, and assign the domain to the project. A name under your Pethost domain, like `hits.sam.pethost.app`, needs no record at all. Either way the app answers over HTTPS, with a certificate that comes and renews by itself.

**In short**

- **A name under your Pethost domain:** `pethost domain add hits.sam.pethost.app`, or Add host in the project's Domains tab. HTTPS at once, no DNS.
- **A domain you own:** a CNAME from `www.example.com` to your machine's name (`pethost machine` shows it), then add the name the same way.
- **The root domain**, `example.com`, takes an ALIAS record (ANAME, CNAME flattening). Never an A record with an IP address.
- **HTTPS** comes from Let's Encrypt once the name resolves to your machine, and renews itself. At Cloudflare, set the record to DNS only.

## Give your app a name under your Pethost domain

Your account comes with a Pethost domain, `sam.pethost.app` for the account sam, and any name one label under it works at once, with HTTPS. Add as many as you like. The project `counter`, the Flask and Redis hit counter from [Deploy a Docker Compose app](https://pethost.dev/docs/deploy-docker-compose/), answers at `counter.sam.pethost.app`; here it gets a second name.

### Step 1: Pick a name one label deep

`hits.sam.pethost.app` works, and so does `sam.pethost.app` itself. `api.hits.sam.pethost.app`, two labels deep, is refused: the domain's certificate does not cover it.

### Step 2: Add it

In the panel, open the project's **Domains** tab, type the name under the hosts and click **Add host**. The new name starts with the routes of the Project URL, the project's first address. Or, from the project's folder:

```
$ pethost domain add hits.sam.pethost.app
counter (.pethost)
✓ hits.sam.pethost.app → web:5000
https://hits.sam.pethost.app
```

### Step 3: Open it

```
$ curl https://hits.sam.pethost.app/
Hello from Pethost! I have been seen 8 time(s).
```

**The project's Domains tab.** Each name with its certificate and its routes, and the field that adds one: a new name starts with the Project URL's routes.

![The Domains tab of the project counter in the Pethost panel: counter.sam.pethost.app, the Project URL, and hits.sam.pethost.app, both HTTPS and routed to web:5000, and www.example.com typed in the Add host field.](https://pethost.dev/shots/docs-domains.webp)

## Connect a domain you own

To point a domain you bought, here `www.example.com`, at your app, you make one DNS record. Make it before you add the name: the machine asks Let's Encrypt for the certificate the moment the name is added, so a name that already resolves gets it on the first try.

### Step 1: Find your machine's name

It looks like `k7f3q2xy.pethost.network`. `pethost machine` shows it on the line Name, and the Domains tab names it under its form. Point at the name, never at the machine's IP address, which may change while the name stays.

### Step 2: Make a CNAME record at your DNS host

**The record for www.example.com**

| Field | Value |
| --- | --- |
| Type | CNAME |
| Name (or Host) | `www` |
| Target (or Value) | `k7f3q2xy.pethost.network`, your machine's name |

Delete any A, AAAA or other record on `www` first: a CNAME stands alone at its name. At Cloudflare, set the record's proxy status to **DNS only**, the grey cloud.

### Step 3: Wait until the name resolves

```
$ dig +short www.example.com
```

It prints your machine's name and, under it, an IPv4 address (on Windows: `nslookup www.example.com`). Nothing yet means the record has not reached you: GoDaddy says most changes take effect within an hour, some up to 48 hours.

### Step 4: Add the name in Pethost

In the panel: the Domains tab, the name, **Add host**. Or with `pethost`, which names the record once more:

```
$ pethost domain add www.example.com
counter (.pethost)
✓ www.example.com → web:5000
One step is yours, where you manage the domain's DNS:
  www.example.com   CNAME   k7f3q2xy.pethost.network
  (if the name is the domain itself, which takes no CNAME: ALIAS there, never an IP address)
The certificate comes by itself once the name resolves:  pethost domain
http://www.example.com
```

### Step 5: Check that HTTPS works

`pethost domain` lists each address with its certificate: `no certificate yet: it comes once the name resolves to your machine`, then `certificate until` a date, `renewed by itself`, on an `https://` address. In the panel, the host goes from **Waiting for a certificate** to **HTTPS**.

## Use the root domain (example.com)

DNS allows no CNAME on a domain's root, `example.com` itself. Many DNS hosts have a record that works like one there: ALIAS, also called ANAME or CNAME flattening. Make it from the root (`@`) to your machine's name, then add `example.com`:

```
$ pethost domain add example.com
counter (.pethost)
✓ example.com → web:5000
One step is yours, where you manage example.com's DNS:
  example.com   ALIAS   k7f3q2xy.pethost.network   (a domain's apex takes no CNAME; never an IP address)
The certificate comes by itself once the name resolves:  pethost domain
http://example.com
```

**The record at common DNS hosts**

| DNS host | www.example.com | example.com |
| --- | --- | --- |
| [Cloudflare](https://developers.cloudflare.com/dns/cname-flattening/) | CNAME, DNS only | CNAME at `@`, flattened by itself on every plan |
| [Namecheap](https://www.namecheap.com/support/knowledgebase/article.aspx/10128/2237/how-to-create-an-alias-record/) | CNAME | ALIAS record |
| [Porkbun](https://kb.porkbun.com/article/85-how-to-connect-a-root-domain-when-web-host-wont-provide-an-ip-address) | CNAME | ALIAS record |
| [DNSimple](https://support.dnsimple.com/articles/alias-record/) | CNAME | ALIAS record |
| [GoDaddy](https://www.godaddy.com/help/forward-my-domain-12123) | CNAME | No ALIAS: forward the root to www |
| [Amazon Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html) | CNAME | No: its alias records point only at AWS resources |

Where your DNS host has no ALIAS, serve the app at `www.example.com` and send the root there with the registrar's forwarding (GoDaddy's uses HTTPS), or move the DNS to a host that has one.

One app can have both names, or more, each with its own certificate. Pethost redirects neither to the other.

## Let your agent assign the domain

With the Pethost plugin, an agent such as Claude Code or Codex adds the name and tells you the record. Routes sent replace all of a project's routes, so it sends the old ones with the new.

Claude Code

**You say:** Put counter on www.example.com too. The domain's DNS is at Cloudflare.

- GetMachine hostname k7f3q2xy.pethost.network
- GetProject counter: 2 routes, both to web:5000
- DeployProject x_pethost.routes: those 2 and www.example.com → web:5000: succeeded

**The agent answers:** counter answers at www.example.com once the name resolves. At Cloudflare, add one record: www, CNAME, k7f3q2xy.pethost.network, proxy status DNS only. Tell me when it is in, and I'll check the certificate.

GetProject shows the host's address with `https://` once its certificate is served ([Host in the API reference](https://pethost.dev/docs/api/#Host)).

## HTTPS certificates: how they are issued and renewed

A name under your Pethost domain is covered by your domain's certificate, which Pethost orders and renews.

A domain you own gets its own certificate from Let's Encrypt, at no extra cost. Your machine asks for it over HTTP-01: Let's Encrypt looks the name up and fetches a file from it on port 80, so it works only once the name resolves to your machine. The machine asks when the name is added, and again whenever a project on it is deployed or its addresses change, and renews the certificate before it expires.

Until then the name answers over plain HTTP, and `https://` fails to connect; after, plain HTTP is redirected to HTTPS. A project with a password answers only over HTTPS, so its new name waits for the certificate.

## Send a path to another service

One name can lead to several services by path. Had the project an `api` service on port 8000, a route `/api` would send `example.com/api` there while `/` stays with `web`. A path matches whole segments and the longest wins: `/api` takes `/api/users`, not `/apis`.

In the panel, on the host's card: **+ Add route**, the path, service and port, and **Strip the path** if the service expects `/users` for `/api/users`; then **Add route**. `pethost domain add` takes no path. In `compose.yaml`, routes go under `x-pethost`:

compose.yaml

```
x-pethost:
  routes:
    - {host: example.com, service: web, port: 5000}
    - {host: example.com, path: /api, service: api, port: 8000, strip_path: true}
```

The file's `x-pethost` counts at the first deploy only; after it, change routes in the panel or through your agent.

## Remove a name

```
$ pethost domain rm www.example.com
counter (.pethost)
✓ www.example.com is no longer an address of counter.
  To bring it back:  pethost domain add www.example.com web:5000
```

In the panel: **Remove host** on its card, then **Remove**. Delete the DNS record too.

**Mind a published port.** Once no address leads to a port that `compose.yaml` publishes, as the quickstart's `ports:` does, the machine opens that port to anyone, without HTTPS.

## Change your Pethost domain

In **Settings**, under **Domain**, click **Change**, type the new name and click **Change domain**. Names under the old domain stop working at once, and your projects move to the same names under the new one within a minute. A project whose last deploy failed, or whose name another project has, keeps the old name, which then answers nobody until you change it.

You can change it three times in 24 hours, and a name you leave is never given to anyone again, you included. Domains you own are not touched. An agent cannot change it.

**Settings, Domain.** The new name typed, and the names that would move to it.

![The Domain section of the Pethost panel's Settings: sam.pethost.app, a field with samlabs typed before .pethost.app, the warning that names under sam.pethost.app stop working at once, and the Change domain button.](https://pethost.dev/shots/docs-settings-domain.webp)

## When the domain does not work

### No certificate comes

- **The name does not resolve yet**, or `dig` shows an old record's address.
- **It resolved only after you added the name.** The machine asks again at its next deploy or change of addresses. To ask now, have your agent send the same routes again, keeping every host and path. Let's Encrypt allows five failed tries for a name an hour, then one every 12 minutes: hence the record first.
- **An AAAA record on the name.** Let's Encrypt tries IPv6 first, and your machine's name has IPv4 only: delete it.
- **A CAA record without Let's Encrypt.** If `dig CAA example.com` prints any, add `0 issue "letsencrypt.org"`.
- **Cloudflare's proxy**, the orange cloud: the name resolves to Cloudflare instead of your machine. Set it to DNS only.
- **A domain ending in .app or .dev**: browsers open it only over HTTPS, so it shows nothing until the certificate comes.

### The name answers nobody

- **A name of `pethost.app` that is not yours** is refused, with the reason: `hits.tom.pethost.app is not under this account's domain, sam.pethost.app: use hits.sam.pethost.app`. One that came in `compose.yaml` shows the same words as **Unavailable**.
- **A 502:** the service does not listen on the route's port. The project's problem names the ports it does listen on: point the route at one.

## Questions

### How do I point my domain to my app?

Make a CNAME record from the name, such as `www.example.com`, to your machine's name, then add the name in the project's Domains tab or with `pethost domain add`. For the root domain, make an ALIAS record instead.

### Do I need an A record or a CNAME?

A CNAME for a subdomain such as www, and an ALIAS (ANAME, CNAME flattening) for the root domain. Not an A record: the machine's IP address may change, its name stays.

### Is HTTPS free?

Yes: certificates cost nothing on top of your plan, for every name, and renew themselves. Pethost has no free tier; plans start at €9.99 a month.

### Can I use a domain from Namecheap or GoDaddy?

Yes, from any registrar. Namecheap has CNAME and ALIAS records; GoDaddy has no ALIAS, so there the app lives at www and forwarding sends the root domain to it.

### How long does a custom domain take to work?

A name under your Pethost domain works within seconds. A domain you own works once your DNS host publishes the record, and its certificate follows.

Next: [send email from your app](https://pethost.dev/docs/send-email/). Every command is in the [CLI reference](https://pethost.dev/docs/cli/#domain-add).

[PreviousDeploy a Docker Compose app](https://pethost.dev/docs/deploy-docker-compose/) [NextSend email from your app with Resend, SendGrid or Amazon SES](https://pethost.dev/docs/send-email/)

## Run your apps on Pethost

Deploy apps, bots and databases from your agent, GitHub or the browser, as many as fit, at one flat price. Nothing metered, nothing billed on top.

[Host all your projects for €9.99/mo](https://console.pethost.dev/)

Pethost · Stephan Gomer · NIP 1133096755

Pethost

- [Templates](https://pethost.dev/templates/)
- [About](https://pethost.dev/about/)
- [Docs](https://pethost.dev/docs/)
- [Blog](https://pethost.dev/blog/)
- [API](https://pethost.dev/docs/api/)
- [CLI](https://pethost.dev/docs/cli/)
- [Plugin](https://github.com/pethost-dev/plugin)
- [Terms](https://pethost.dev/terms/)
- [Privacy](https://pethost.dev/privacy/)
- [Refunds](https://pethost.dev/refunds/)
- [support@pethost.dev](mailto:support@pethost.dev)

Databases

- [Postgres](https://pethost.dev/postgres/)

Comparisons

- [Coolify vs Dokploy vs CapRover vs Dokku](https://pethost.dev/blog/coolify-vs-dokploy-vs-caprover-vs-dokku/)
- [Coolify Cloud vs Dokploy Cloud](https://pethost.dev/blog/coolify-cloud-vs-dokploy-cloud/)
- [Railway vs Render vs Fly.io pricing](https://pethost.dev/blog/railway-vs-render-vs-fly-io-pricing/)
- [Managed Docker Compose hosting](https://pethost.dev/blog/managed-docker-compose-hosting/)

Alternatives

- [Railway alternatives](https://pethost.dev/blog/railway-alternatives/)
- [Heroku alternatives](https://pethost.dev/blog/heroku-alternatives/)
- [Dokploy alternatives](https://pethost.dev/blog/dokploy-alternatives/)
- [Coolify alternatives](https://pethost.dev/blog/coolify-alternatives/)
- [Render alternatives](https://pethost.dev/blog/render-alternatives/)
- [Sliplane alternatives](https://pethost.dev/blog/sliplane-alternatives/)
