Python 3.x OSError:[Errno 99]尝试绑定地址时出错无法分配请求的地址

Python 3.x OSError:[Errno 99]尝试绑定地址时出错无法分配请求的地址,python-3.x,alibaba-cloud,Python 3.x,Alibaba Cloud,在阿里巴巴免费弹性IP上运行代码时,我收到了这样一条消息: OSError: [Errno 99] error while attempting to bind on address ('147.139.5.81', 31333): cannot assign requested address 下面是在AmazonEC2中正常工作的代码:' ip = '147.139.5.81' #In Amazon EC2, ip will be different start_server =

在阿里巴巴免费弹性IP上运行代码时,我收到了这样一条消息:

OSError: [Errno 99] error while attempting to bind on address ('147.139.5.81', 31333): cannot assign requested address
下面是在AmazonEC2中正常工作的代码:'

ip = '147.139.5.81' #In Amazon EC2, ip will be different

    start_server = websockets.serve(
        hello, ip, 31333
    )

    asyncio.get_event_loop().run_until_complete(start_server)
    asyncio.get_event_loop().run_forever()
ifconfig-a显示

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.31.173.211  netmask 255.255.240.0  broadcast 172.31.175.255
        ether 00:16:3e:01:30:8e  txqueuelen 1000  (Ethernet)
        RX packets 473419  bytes 267646492 (267.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 309017  bytes 92824868 (92.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 72620  bytes 4035134 (4.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 72620  bytes 4035134 (4.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth0:flags=4163 mtu 1500
inet 172.31.173.211网络掩码255.255.240.0广播172.31.175.255
乙醚00:16:3e:01:30:8e txqueuelen 1000(以太网)
接收数据包473419字节267646492(267.6 MB)
接收错误0丢弃0超出0帧0
发送数据包309017字节92824868(92.8 MB)
发送错误0丢弃0溢出0载波0冲突0
低:标志=73 mtu 65536
inet 127.0.0.1网络掩码255.0.0.0
循环txqueuelen 1000(本地环回)
接收数据包72620字节4035134(4.0 MB)
接收错误0丢弃0超出0帧0
发送数据包72620字节4035134(4.0 MB)
发送错误0丢弃0溢出0载波0冲突0
%
dig+short myip.opendns.com@resolver1.opendns.com
显示:

147.139.5.81


有什么问题吗?我使用ip:147.139.5.81访问了此VPS。您必须使用VPC网络类型的ECS实例,因为您的ECS实例的inet是专用ip。对于VPC网络类型的ECS实例,该ECS实例的公网IP在操作系统内不可见,无法绑定


您可以绑定0.0.0.0,使用ECS实例的安全组来允许/阻止到ECS的流量。

有没有办法让操作系统可以看到实例的公共IP?