Mailgun "Domain not found" error in CI
Mailgun returns {"message":"Domain not found: ..."} when the domain segment in the /v3/<domain>/messages URL is not a domain on your account, or is registered in the other region. The credentials may be fine; the domain path is wrong.
What this error means
A Mailgun send returns HTTP 404 with Domain not found: <domain>. It commonly appears after a typo in MAILGUN_DOMAIN or when a US host is used for an EU domain.
< HTTP/1.1 404 NOT FOUND
{"message": "Domain not found: mg.example.com"}Common causes
The domain is misspelled or not verified
The MAILGUN_DOMAIN value does not match a verified domain on the account, so the path resolves to nothing.
Region mismatch
An EU-region domain queried against api.mailgun.net (US) is reported as not found.
How to fix it
Use a verified domain and matching host
- Confirm the exact domain name in the Mailgun dashboard.
- Set
MAILGUN_DOMAINto that value. - Use the US or EU API host that matches the domain region.
MAILGUN_DOMAIN=mg.example.com
curl -sS --user "api:$MAILGUN_API_KEY" \
"https://api.mailgun.net/v3/$MAILGUN_DOMAIN/messages" -F ...Store the domain as a variable
Pin the domain as a workflow variable to prevent typos across steps.
env:
MAILGUN_DOMAIN: ${{ vars.MAILGUN_DOMAIN }}How to prevent it
- Reference only verified domains from CI.
- Match the API host to the domain region.
- Keep the domain in a variable to avoid typos.