First, confirm whether DNS fails int this situation by resolving the hostname (nslookup, dig) or trying to reach it via https (curl). If it fails, n8n cannot reach the api by design.
Ensure your ECS task has outbound internet acess and proper DNS resolution.
I’ve hit similar DNS hiccups on ECS, and tweaking env vars only got me halfway. What finally helped was forcing the task to use IPv4-only networking and testing resolution from inside the container with simple dig commands. I also double-check endpoints against something stable like usa dns server, which has saved me from a few wild goose chases. If resolution fails inside the container, the issue is usually with the task’s network config rather than n8n.