无法将 ip 绑定到 AWS 上的 python 套接字
我正在 AWS EC2 上使用套接字运行一个简单的 python 脚本。 绑定公共 IP 时,我收到一条错误消息,告诉我无法分配请求的地址。当使用私有 IP 时(只是为了确定而尝试)我没有收到错误,但也无法连接。在 AWS EC2 上运行脚本时应该使用哪个 IP?
# Open socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("<public ip>", 5000))
# Error when running the script
server_socket.bind(("<public_ip>", 5000))
OSError: [Errno 99] Cannot assign requested address
I am running a simple python script with sockets on AWS EC2.
When binding the public ip I get an error telling me I cannot assign the requested address. And when using the private ip (tried it just to be sure) I don't get an error but can't connect either. Which ip am I supposed to use when running my script on AWS EC2?
# Open socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("<public ip>", 5000))
# Error when running the script
server_socket.bind(("<public_ip>", 5000))
OSError: [Errno 99] Cannot assign requested address
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论