I have a simple REST API built using FastAPI. The API takes in a file and does some processing to it, and saves it in S3. The server is deployed on ECS Fargate.
When I run the server locally (on my development machine), everything works fine. But when I hit the endpoint on AWS (using API Gateway), I get the following error, after which the task essentially crashes, and is restarted.
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='publicsuffix.org', port=443): Max retries exceeded with url: /list/public_suffix_list.dat (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f594acc4350>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
My ECS cluster does not have internet access – it is in a private subnet. But what I don’t understand is why it’s trying to make a request to that endpoint at all? It’s not part of my API code.
I have another endpoint that also uploads to S3, and that works fine, so I’ve confirmed S3 is accessible by the container (I added a Gateway Endpoint for it).