Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Custom domains

Connect a domain you own, add the DNS records Spacefast asks for, get a certificate, and make it the Space's primary address

Point a domain you own at a Space, then make it the Space’s primary address, the one Spacefast reports as its live URL.

Don’t have a domain yet? Find and buy one at cost, then come back here to connect it.

A domain belongs to a team, not to a Space. You add it once to the team’s inventory, then assign it to a Space. One hostname serves exactly one Space; one Space can hold many hostnames.

Connect a domain

Add the domain to a Space

One command creates the domain on the team, assigns it to the Space, and queues the first DNS check.

sf domains add example.com --space my-site

Add --role primary to make it the Space’s live address as soon as it verifies.

Open the Space, go to Domains, and click Add domain. The wizard walks Enter, Setup, Verify. On the Enter step a root domain asks you to pick a Primary address, either the apex or www.

Over the API it is POST /v1/domains to create the record, then PATCH /v1/domains/{domainId} with a spaceId to assign it. See the API reference.

Add the DNS records at your DNS host

The command prints them, and the dashboard’s DNS records card shows the same list with copy buttons. Every record is required. See the table below for the shape.

Check the domain

sf domains check example.com --space my-site

Spacefast also rechecks on its own. While a domain is pending, it checks every 15 to 60 minutes at first, depending on what it waits for, and backs off to as long as seven days if nothing changes. Once the domain is live, the next check comes about three weeks before its certificate expires. A manual check only shortens the wait.

Make it primary

sf domains add example.com --space my-site --role primary

Edit the row on the Space’s Domains page and choose Serve this space with Primary domain, the live URL.

Once the domain reaches active, it becomes the Space’s liveUrl.

The DNS records

An unassigned domain has no records to show. Instructions appear once the domain is assigned to a Space, which is why sf domains add assigns in the same command.

Each record the API returns has four fields: type, name, value, and purpose. Adding the apex example.com usually produces three records, because www.example.com is set up with it.

Type Name Value Purpose
A example.com 192.0.79.157 routing
A example.com 192.0.79.175 routing
CNAME www.example.com example.com routing

A subdomain like app.example.com usually gets just its two A records. The addresses are generated for your hostname, so copy the exact values from your own output rather than the ones above.

When a TXT record shows up

Most domains need no TXT record. One appears only when the hostname is already in use elsewhere and you have to prove it is yours (see Domain verification records for how they interact with older proofs):

  • Another host still holds it. The record is named for the hostname, its value starts with atomic-domain-, and the domain waits until it is published. Remove any CNAME at that name first; a TXT record cannot sit beside one.
  • Another Space serves it. Adding it to this Space creates a claim instead of failing, even when the other Space is on your team, and returns a _spacefast-claim.<domain> TXT record made for this claim. Publish it at your DNS host and verify. Once Spacefast sees it, the domain moves to this Space and the old Space stops serving it. A claim doesn’t expire, and it holds nothing until you prove it. If you manage both Spaces, you can also remove the domain from the other one and add it here.

Keep exactly one atomic-domain- record per hostname. Two of them, even when one is correct, make the claim fail.

Certificates are provisioned and renewed automatically once the hostname can be validated. See TLS certificates for issuance checks and retries, and IP ranges for inbound and outbound address behavior.

Apex and www travel together

If you add a registrable apex or its www hostname, Spacefast sets up both. example.com adds www.example.com, and www.example.com adds example.com. Any other subdomain, like app.example.com, is connected on its own.

Whichever of the pair serves the Space, the other redirects to it with a 308, which Spacefast creates for you. If only one of the two is bound, the domain reports a companion_hostname_unbound diagnostic that says what visitors who type the other one will get.

The apex is decided by the public suffix list, not by counting labels. example.co.uk is an apex; www.example.com is not.

Verification states

verification.status on the domain record says whether you currently have proven control of the DNS.

Status What it means What to do
not_required The domain is in the team inventory but not assigned to a Space. Assign it to a Space.
pending Assigned, waiting for the records to show up in public DNS. Add the records, then wait or run sf domains check.
verified A current positive signal proves control. Nothing.
failed No current proof. Either the records were never observed, or the domain verified once and later stopped verifying. Run sf domains diagnostics to see which records are observed.

When a domain that used to work shows failed, check whether someone edited the zone. It doesn’t mean the Space is down.

A verification failure doesn’t take a live Space down right away. Routes and certificates stay in place while the domain verifies again. Only a failure that lasts past the notice window blocks the attachment.

Certificates

A certificate is issued once DNS points at Spacefast. The state is reported per hostname.

SSL status What it means
missing No certificate information yet. Usually DNS has not landed.
pending Issuance is in progress.
active The hostname has a certificate and serves HTTPS.
broken Issuance failed and is blocked by something in the zone.

broken carries a reason, the last error, a retry date, and a failure count. The usual cause is a CAA record that does not permit the issuing authority. Fix the record, then retry:

sf domains diagnostics example.com --space my-site

The retry route is POST /v1/domains/{domainId}/ssl/retry, or Verify in the connect wizard. It refuses with domain_not_bound when the domain has no Space.

Manual verification checks and certificate retries are each limited to 6 per hour per domain and 120 per hour per team. Past that, they return rate_limited. Retrying more often doesn’t make DNS propagate or a certificate issue faster.

Primary, and redirecting a whole host

A domain assigned to a Space either serves the Space or redirects away from it, never both.

Primary is the one assigned, active domain that Spacefast reports as the Space’s liveUrl. Setting a new primary releases the previous holder. A domain that is verifying or blocked can be marked primary, but the live URL stays on the default hostname until it reaches active.

Redirect sends the entire host somewhere else:

sf domains add www.example.com --space my-site --role redirect --redirect-to example.com

--redirect-status accepts 301, 302, 307 or 308 and defaults to 308. In the dashboard the row’s edit form offers Redirect to another domain with a Redirect status select.

A redirecting domain cannot be primary. Setting a redirect on a domain that held the primary slot releases the slot; promoting a redirecting domain to primary without clearing the redirect fails with domain_primary_redirect_conflict.

The redirect target is either an absolute URL or another Space. There is no path-scoped domain redirect. Per-path rules live in the published bundle, on Redirects, rewrites, and headers.

Moving a domain to another Space

Unassign, then assign:

sf domains remove example.com --space old-site
sf domains add example.com --space new-site

Adding a domain another Space still serves creates a claim with a TXT record to publish, as described in When a TXT record shows up. Reassigning while the previous teardown is still draining fails with domain_detach_in_progress. Wait for the unassign to finish. The --wait flag on sf domains remove does that for you and is on by default.

Removing versus deleting

These are two different operations. The CLI only unassigns.

Action What happens How
Unassign The domain stops routing to the Space and stays in the team’s inventory, ready to reuse. sf domains remove <domain> --space <space>, or PATCH /v1/domains/{domainId} with {"spaceId": null}
Delete The inventory record is gone. DELETE /v1/domains/{domainId}, or Delete domain on the team’s domain detail page

sf domains remove prompts with “Remove this domain from the space?” and unassigns. Deleting requires the domain to be unassigned first, otherwise it refuses with domain_in_use.

The team’s domain inventory

Every domain a team owns lives on one page, whether or not it is assigned. In the dashboard, open the team and go to Domains. Rows are labelled Apex or Subdomain, and each one links to a detail page with Status, Space, Provider and Added, plus Check and Visit actions and a DNS section.

Over the API, GET /v1/domains lists the team’s inventory and GET /v1/spaces/{spaceId}/domains lists what one Space serves on. The CLI’s sf domains list is the per-Space list.

Two teams can add the same hostname, but only one Space serves it. A team that publishes its claim’s TXT record moves the hostname to its own Space.

Adding a domain also counts against a plan limit, measured in external domain groups. One group is a registrable apex plus all of its subdomains. Over the limit, the add fails with domain_quota_exceeded.

Troubleshooting

Run this first. It reports every hostname in the setup with observed DNS, the TXT state, and the certificate state:

sf domains diagnostics example.com --space my-site
Diagnostics for example.com:
example.com      purpose=apex  dns=ok             txt=ok        ssl=active
www.example.com  purpose=www   dns=not_configured txt=missing   ssl=missing

Diagnostic codes

Code Meaning Fix
dns_records_missing The required records have not been observed. Verification keeps polling. Add the records at your DNS host.
verification_required The hostname needs proof of DNS control to keep serving. Add the verification TXT record.
domain_ownership_required Another Space serves this hostname. Publish the claim’s TXT record, then verify to move it here.
ssl_pending Certificate issuance is in progress. Wait.
ssl_renewal_blocked A DNS record, usually CAA, is blocking issuance. Fix the record, then retry HTTPS.
provider_pending The edge has not observed the hostname yet. Wait.
provider_rejected The hostname claim was rejected. Contact support.
provider_error Attaching or detaching the hostname failed. Contact support.
companion_hostname_unbound You bound the apex but not www, or the other way round. Add the twin as a second domain or as a redirect.
provider_cannot_host The hostname looks like it is in use with another host, and nothing has proved ownership yet. Finish the DNS setup and add the TXT record to claim it.
nameserver_divergence The observed nameservers differ from the expected set. Informational. It never changes serving.

Errors when adding or assigning

Code Status Meaning
invalid_domain_name 400 Not a hostname: no dot, an IP literal, over 253 characters, or not convertible to ASCII.
domain_wildcard_label 400 A label contained *. Add the apex or the concrete hostname instead.
domain_reserved_suffix 400 The hostname ends in a Spacefast-managed suffix.
managed_domain_protected 400 You passed the id of a built-in space.fast or view.fast hostname.
domain_already_exists 409 Adding a hostname to the team’s domain list when the team already has it. Adding it to a Space attaches it, or creates a claim while another Space still serves it.
domain_quota_exceeded 409 The plan’s external domain group limit is reached.
domain_in_use 409 The hostname is already on this Space, a previous attachment is still being removed, or you tried to delete a domain that is still assigned.
domain_detach_in_progress 409 A previous unassign is still draining.
domain_not_bound 409 You set a redirect, or retried SSL, on a domain with no Space.
domain_primary_redirect_conflict 400 A redirecting domain cannot be primary. Clear the redirect first.
rate_limited 429 Over 6 verify or SSL retries in an hour for this domain, or 120 for the team.

Checking before you commit

GET /v1/domains/preflight?name=example.com runs the same name validation and serving check as adding the domain, so you see blocking problems before any record exists. Its canHost result is advisory. A false still lets you add the domain and claim it with the TXT proof, and null means the check was unavailable rather than negative.

Next steps

For command options, use CLI domains. Once the address is ready, read traffic stats to see visits.

Last updated on

Was this page helpful?