---
title: Custom domains
description: Serve a public or link site, or a sandbox's published port, at a domain of your own, like www.example.com or example.com, with the DNS records to set, verification, automatic certificates and a primary domain.
---

A [site](/docs/publish/sites/) can be served at domains of your own, like `www.example.com` or `example.com`, besides its address under `on.pols.so`. You add the domain and set one DNS record; pols checks that the record points to your site, gets a certificate for the domain from Let's Encrypt, renews it, and serves the site there over HTTPS.

Custom domains work for **public** and **link** sites (see [Who can open a site](/docs/publish/access/)). A private site cannot have custom domains yet. A custom domain can also serve a sandbox's [published port](/docs/access/ports/) instead of a site (see [A sandbox's port](#a-sandboxs-port)).

## Add a domain

1. Open the site on [my.pols.so](https://my.pols.so/account/sites) and go to its **Domains** tab.
2. Enter the domain, for example `www.example.com`, and choose **Add**.
3. Set the DNS record the tab shows at your domain's DNS provider (see [DNS records](#dns-records)).

From the CLI:

```sh
pols domains add my-site www.example.com   # prints the DNS records to set
```

Adding a domain checks its DNS at once. The site stays at `<name>.on.pols.so` as well.

## DNS records

**A subdomain** (`www.example.com`, `docs.example.com`): a `CNAME` record to your site's host.

| Type | Name | Value |
| --- | --- | --- |
| `CNAME` | `www` | `<your site>.on.pols.so` |

**An apex domain** (`example.com`): an apex cannot have a CNAME, so point it at the pols edge with an `A` record, and optionally an `AAAA` record for IPv6. The Domains tab and `pols domains add` show the exact addresses. A provider's ALIAS record, or a flattened CNAME, to `<your site>.on.pols.so` works too.

| Type | Name | Value |
| --- | --- | --- |
| `A` | `@` | the IPv4 address the Domains tab shows |
| `AAAA` | `@` | the IPv6 address the Domains tab shows (optional) |

To serve both `example.com` and `www.example.com`, add each as a domain of its own, with its own record, then make one of them [primary](#primary-domain-and-redirects): the other redirects to it.

A CNAME to another site's host, or to any other pols host, does not count for your site, even though it resolves to the same addresses.

On **Cloudflare**, set the records to **DNS only** (grey cloud). With the proxy on, the domain points to Cloudflare instead of pols, so it cannot be verified and pols cannot get its certificate.

## Status

The Domains tab follows each domain live; `pols domains ls` and the API show the same as `status`.

| On the Domains tab | `status` | What it means |
| --- | --- | --- |
| Waiting for DNS | `pending` | The records do not point to your site yet, or the last lookup failed. |
| Verification needed | `pending` | Another site uses this domain. Add the TXT record the tab shows (see [A domain another site uses](#a-domain-another-site-uses)). |
| Invalid configuration | `pending` | The records point somewhere else, or to another pols site. |
| Issuing certificate | `issuing` | The domain is verified, and pols is getting its certificate. This usually takes under a minute. |
| Valid configuration | `active` | The site is served at the domain over HTTPS. |
| Invalid configuration | `misconfigured` | The domain was verified, but its records no longer point to your site (see [When the DNS changes](#when-the-dns-changes)). |

pols checks a new domain every minute in its first hour, then less often: every 10 minutes for its first day, hourly for its first week, then every 6 hours. **Check now** on the tab, or `pols domains check SITE DOMAIN`, checks at once. DNS changes can take a while to reach the public resolvers pols asks (`1.1.1.1` and `8.8.8.8`), depending on your records' TTL.

## Certificates

Once a domain is verified, pols gets a certificate for it from Let's Encrypt on its own, without waiting for a visitor, and renews it 30 days before it expires. You do not upload or manage certificates. Plain HTTP requests to the domain redirect to HTTPS.

A custom domain gets no `Strict-Transport-Security` header from pols, so your other hosts are not bound to HTTPS by it.

## A domain another site uses

pols serves a domain for one site only. If another site, of your org or another one, already has it, your domain shows **Verification needed** and a TXT record:

| Type | Name | Value |
| --- | --- | --- |
| `TXT` | `_pols` (`_pols.www` for `www.example.com`) | `pols-verify=...` |

Once the TXT record is in place and the domain's DNS points to your site, your site takes the domain over and the other site stops being served there. Only someone who controls the domain's DNS can do this. Within your own org, a domain can belong to one site only: remove it from the other site first.

## When the DNS changes

pols re-checks every verified domain every 6 hours. If its records stop pointing to your site, it shows **Invalid configuration** (`misconfigured`), pols re-checks it every 30 minutes, and your org's users get an email. pols keeps serving the site at the domain for 24 hours; if the records are still wrong after that, it stops, the domain goes back to pending and needs verifying again, and your org's users get another email. A lookup that merely fails, like a timeout, changes nothing.

## A sandbox's port

A custom domain can serve a [published port](/docs/access/ports/) of a sandbox instead of a site, with the same DNS records, verification, certificates, statuses, primary domain and limits. A subdomain's `CNAME` goes to the port's host, `<host label>-<port>.on.pols.so`; an apex gets the same `A` and `AAAA` records as for a site.

```sh
pols domains add example.com --sandbox web --port 8080   # prints the DNS records to set
pols host web 8080 --public --domain www.example.com     # publish the port and add the domain in one step
pols domains ls --sandbox web --port 8080
```

The other `pols domains` commands take `--sandbox` and `--port` in place of the site the same way.

- The edge serves the port at the domain exactly as at its own host: public or private as the port is, waking the sandbox from standby, with WebSockets. A private port's login link works on the domain too, with the domain as its host; `pols host` prints it.
- The port must be published to add a domain. Unpublishing it keeps its domains, verified, and the domain answers `404` until the port is published again. Deleting the sandbox removes its domains.
- An org's 20 custom domains count its sites' and ports' domains together; a port has at most 10.

## Move a domain

A domain your org has on one site or port can move to another without verifying it again or getting a new certificate: `pols domains add DOMAIN --sandbox web --port 8080 --move` (or `pols domains add SITE DOMAIN --move`, or `pols host web 8080 --domain DOMAIN --move`). Without `--move`, adding it is refused (`409`). Its DNS is checked again right away, so for a subdomain point its `CNAME` at the new host first. The edge serves the domain at its new target once it next refreshes its list of domains, within 30 seconds, and answers `404` there until then. A moved domain is not primary.

## Primary domain and redirects

Choose **Make primary** on one of a site's verified domains (`pols domains primary SITE DOMAIN`, or `pols domains primary DOMAIN --sandbox web --port 8080` for a port). The site's other custom domains then redirect to it with a `308`, keeping the path and query: `example.com` to `www.example.com`, or the other way round. **Unset primary** (`pols domains primary SITE DOMAIN --unset`) ends the redirects.

- The redirects start once the primary domain has its certificate. If it later stops being served, for example because its DNS moved away, the redirects pause until it is served again.
- Redirects are cached by browsers for up to an hour (`Cache-Control: max-age=3600`), so after you switch the primary domain or unset it, returning visitors may take up to an hour to follow the change.
- `<name>.on.pols.so` keeps serving the site without a redirect, and previews of branches and pull requests stay on their own `on.pols.so` addresses.

## Remove a domain

Choose **Remove** on the domain, or run `pols domains rm SITE DOMAIN`. The site stops being served there within seconds. Deleting a site, or a sandbox, removes its domains too.

**Remove the domain's DNS records at your provider as well.** While they still point to pols, anyone could add the domain to their own site.

## Private sites

A private site cannot have custom domains yet: adding one is refused. If you switch a site that has custom domains to private, its domains stay on the site but are not served (they answer "There is nothing at"); switch it back to public or link and they are served again. On a link site's custom domain, a visitor without the share link sees that page too, rather than a login.

## Limits

- An org has at most 20 custom domains across its sites and ports, a site or port at most 10.
- pols' own domains (`pols.so` and everything under it), public suffixes like `co.uk` or `github.io`, wildcards and IP addresses cannot be added. Internationalised names are stored in their ASCII form (`xn--...`).
- DNS checks, from adding a domain and from Check now, are limited per org: bursts of 30, then one every 10 seconds (`429` beyond that).

## From the CLI, agents and the API

```sh
pols domains add my-site www.example.com      # add it; prints the DNS records to set
pols domains ls my-site                       # status, primary, redirects
pols domains get my-site www.example.com      # one domain and the records it still needs
pols domains check my-site www.example.com    # check its DNS now
pols domains primary my-site www.example.com  # make it primary; --unset to have none
pols domains rm my-site www.example.com       # remove it
pols domains ls --sandbox web --port 8080     # the same for a sandbox's port
```

See [`pols domains`](/docs/reference/cli/domains/) for every flag. Agents have the same through the [MCP server](/docs/agents/mcp/)'s `site_domain_add`, `site_domain_list`, `site_domain_check`, `site_domain_set_primary` and `site_domain_remove` tools (with `sandbox` and `port` in place of `site` for a port, and `move` on `site_domain_add`), Node.js code through the [TypeScript client](/docs/agents/typescript/)'s `pols.sites.domains` and `pols.ports.domains` (`list`, `get`, `add`, `check`, `setPrimary`, `remove`), and Python through the [Python client](/docs/agents/python/)'s `pols.sites.domains` and `pols.ports.domains`.

| Endpoint | What it does |
| --- | --- |
| `GET /v1/sites/{site}/domains` | the site's domains |
| `POST /v1/sites/{site}/domains` | add one: `{"domain": "www.example.com"}`; `"move": true` moves it from another of your sites or ports |
| `GET /v1/sites/{site}/domains/{domain}` | one domain, with its `status`, the `records` to set and its verification |
| `POST /v1/sites/{site}/domains/{domain}/check` | check its DNS now |
| `PATCH /v1/sites/{site}/domains/{domain}` | `{"primary": true}` makes a verified domain primary; `false` unsets it |
| `DELETE /v1/sites/{site}/domains/{domain}` | remove it |

A port's domains have the same endpoints under `/v1/sandboxes/{sandbox}/ports/{port}/domains`.
