I'm using Python 2.6 and Windows Server 2008.

我正在使用Python 2.6和Windows Server 2008。

The server has two IP addresses 1 internal, 1 external.

服务器有两个IP地址1个内部,1个外部。


I need Python to use the external IP address, but while doing so I get this:

我需要Python来使用外部IP地址,但是这样做我得到了这个:

socket.error: [Error 10049] The requested address is not valid in its context

socket.error:[错误10049]请求的地址在其上下文中无效


To be more precise I'm using Django's runserver command for who is familiar with it

更准确地说,我正在使用Django的runserver命令来熟悉它


Edit:

ipconfig only brings up the internal IP address, while all services I have running are using the external IP without any problems!

ipconfig只显示内部IP地址,而我运行的所有服务都使用外部IP而没有任何问题!


Any ideas?

有任何想法吗?

1 个解决方案

#1


15

That's an error Windows gives when you're trying to bind to an address on the local machine that's not assigned to any of the adapters on the machine. If ipconfig doesn't show it, you can't bind to it.

当您尝试绑定到本地计算机上未分配给计算机上任何适配器的地址时,Windows会出现这种错误。如果ipconfig没有显示它,则无法绑定它。

If the external address is on a router that is NAT'ing requests from it to the server's internal address, you can't bind to it because it's on a different machine. This is probably the case. You might want to bind to socket.INADDR_ANY (or its Django equivalent). This will bind to all addresses that are on the machine right now.

如果外部地址在路由器上,即NAT请求它到服务器的内部地址,则无法绑定到它,因为它位于不同的计算机上。情况可能就是这样。您可能希望绑定到socket.INADDR_ANY(或其Django等效项)。这将绑定到机器上的所有地址。

Also note that if the external address is NAT'ed to your internal one, binding to the internal one should be enough.

另请注意,如果外部地址是NAT内部地址,则绑定到内部地址就足够了。

更多相关文章

  1. python中查看变量内存地址的方法
  2. Vue绑定内联样式问题
  3. [Linux] 总结各系统 双网卡绑定
  4. linux socket 程序被ctrl+c或者异常终止,再次起程序时提示该端口
  5. CentOS 7下配置IP地址
  6. 如果后台的SVN服务器IP地址更改了,如何修改客户端的连接url呢?
  7. Linux 修改ip地址
  8. linux配置虚拟IP地址方法
  9. 使用.NetCore在Linux上写TCP listen 重启后无法绑定地址

随机推荐

  1. android实现进度条ProgressDialog
  2. android gridview setOnItemClickListene
  3. Android文件存储
  4. Android 结束进程的方法
  5. openGL 简单demo
  6. Android 返回键退出
  7. Android的NDK开发(2)————利用Android
  8. 解决activity加上Theme.Translucent.NoTi
  9. android 广播 android Service 开机启动
  10. RecyclerView 滚动条的显示与隐藏