How to attach or remove a domain
View as MarkdownAttach a custom domain to your hosted app.
Overview
After you deploy your app, you can attach a custom domain to make it accessible through a friendly URL instead of the default hosting domain. Domain attachment is optional and your app is fully functional without it.
Only domains you own can be attached to your app. After attachment, traffic to that domain routes to your hosted application.
DNS routing
For the domain to route correctly to your app, your domain's DNS must point to GoDaddy's hosting infrastructure. If registered with GoDaddy, this is often automatic. For other registrars, update your domain's nameservers or DNS records accordingly.
Go to Deploy your Node.js app for the core deployment flow. Domain attachment happens after your app is live.
Prerequisites
The following prerequisites are required before you can attach a domain to your app:
- a Personal Access Token with the
hosting.domain:writescope - a deployed app
Go to Deploy your Node.js app for more information on deploying an app.
- a domain you own (already registered with GoDaddy or another registrar)
Attach a domain to an app
POST /apps/{appId}/domains attaches a domain to your app and initiates DNS verification. Returns 202 Accepted with a domain attachment and enters DNS verification. DNS propagation can take a few minutes and your app is accessible at the domain after DNS resolves.
-
Attach the domain:
curl -s -X POST "$BASE_URL/v1/hosting/apps/$APP_ID/domains" \ -H "Authorization: Bearer $GODADDY_PAT" \ -H "Content-Type: application/json" \ -d '{ "hostname": "my-app.example.com" }'
Remove a domain
To remove a domain attachment, use DELETE /apps/{appId}/domains/{domainId}. This detaches the domain from the app but does not modify DNS records at your registrar.
-
Remove a domain:
curl -s -X DELETE "$BASE_URL/v1/hosting/apps/$APP_ID/domains/$DOMAIN_ID" \ -H "Authorization: Bearer $GODADDY_PAT"
Success returns 204 No Content.
Common errors
The following table lists common errors when attaching a domain:
| Status | Cause | Action |
|---|---|---|
400 | Invalid domain format | Verify the domain is a valid FQDN (e.g., my-app.example.com) |
401 | Expired or revoked PAT, or missing scope | Go to Hosting core concepts for the scopes you need |
404 | App not found | Verify the app ID is correct |
409 | Domain already in use | The domain is already attached to this app or another app on your account |
Agent & Automation Notes
hosting.domain:writeRelated
API References
Concepts
Last updated on
How is this guide?