0

I am getting connection timeout error with VPC enabled but working fine without enabled VPC.

{
  "errorMessage": "HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-base-cased/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fd7f0a07040>, 'Connection to huggingface.co timed out. (connect timeout=30)'))",
  "errorType": "ConnectTimeout",
  "requestId": "",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.10/importlib/__init__.py\", line 126, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n",
    "  File \"<frozen importlib._bootstrap>\", line 1050, in _gcd_import\n",
    "  File \"<frozen importlib._bootstrap>\", line 1027, in _find_and_load\n",
    "  File \"<frozen importlib._bootstrap>\", line 1006, in _find_and_load_unlocked\n",
    "  File \"<frozen importlib._bootstrap>\", line 688, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 883, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 241, in _call_with_frames_removed\n",
    "  File \"/var/task/spellCorrection_rest_app.py\", line 4, in <module>\n    response = requests.head(url, timeout=30)  # Increase the timeout value as needed\n",
    "  File \"/var/task/requests/api.py\", line 100, in head\n    return request(\"head\", url, **kwargs)\n",
    "  File \"/var/task/requests/api.py\", line 59, in request\n    return session.request(method=method, url=url, **kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 589, in request\n    resp = self.send(prep, **send_kwargs)\n",
    "  File \"/var/task/requests/sessions.py\", line 703, in send\n    r = adapter.send(request, **kwargs)\n",
    "  File \"/var/task/requests/adapters.py\", line 507, in send\n    raise ConnectTimeout(e, request=request)\n"
  ]
}

1 Answer 1

0
You need to create a NAT Gateway in either one of your Public subnets 'subnet-0a41b43c04095c248' and 'subnet-00303000' of the VPC. Please follow the documentation[1] to get the detailed steps of creating a NAT Gateway.

Edit the route tables of the private subnets which are associated with your Lambda function, to allow the traffic to the destination 0.0.0.0/0 with the target set to the NAT Gateway, that you created in the public subnet.

Ref: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.