It is likely because you need to explicitly whitelist your server’s IP address with Mailgun via the IP Allowlist.
- To the following page: https://app.mailgun.com/app/account/security/api_keys
- Click the API security tab
- In the IP whitelist section, click the Add to whitelist button.
- Finally, enter the IP / CIDR and click the Save IP address/CIDR button.