简体   繁体   中英

Unable to resolve host name on AWS Lambda

I am trying to reach an API which is deployed on an EC2 server.

req = requests.post(http://xxxxx:10002/scan, json=d)
# xxxxx is the EC2 server hostname

When I execute the code on my machine it works fine. But when I try it on AWS Lambda it returns this error

 "errorMessage": "HTTPConnectionPool(host=host, port=10002): Max retries exceeded with url: /scan_ea (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f2000b81e48>: Failed to establish a new connection: [Errno -2] Name or service not known',))",
  "errorType": "ConnectionError"

I doubt a.network error but I dont understand why is it working on my machine. I didnt do any particular.network configurations before executing the code.

Thank you.

AS @ORP suggested, I only had to check lambda's SG and inbound/outbound rules were not allowing traffic to port 10002

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM