Python 运行应用程序时出现“错误:无法分配该 IP 地址”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15841295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Error: That IP address can't be assigned-to" when running app
提问by JavierRR
Whenever I'm trying to launch a Django server app with a LAN ip I receive the error:
每当我尝试使用 LAN ip 启动 Django 服务器应用程序时,我都会收到错误消息:
Django version 1.4.1, using settings 'servidorMain.settings'
Development server is running at http://192.168.1.XX:8080/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.
In localhost it works perfectly. I also was checking the network configuration and I think all is correct so I dont see where is the problem.
在本地主机它完美地工作。我也在检查网络配置,我认为一切都是正确的,所以我看不出问题出在哪里。
Thanks in advance.
提前致谢。
采纳答案by Vladislav Mitov
Use:
用:
python manage.py runserver 0:8000
回答by MostafaR
It is equivalent to error code #99 in c language errors list, It's described by this term:
相当于c语言错误列表中的错误代码#99,用这个词来描述:
Cannot assign requested address
无法分配请求的地址
It is not a permission problem, because permission's error code is different so I think it's because you have not that IP address set on your computer. When you try to run server on an specified IP address, you should have it set on one of your network interfaces.
这不是权限问题,因为权限的错误代码不同,所以我认为这是因为您的计算机上没有设置该 IP 地址。当您尝试在指定的 IP 地址上运行服务器时,您应该将其设置在您的网络接口之一上。
Simply the IP address you're trying to run server on it is not your current IP address.
只是您尝试在其上运行服务器的 IP 地址不是您当前的 IP 地址。
回答by Manan Patel
You should check with your IP, as mine was changed and was getting the same error
您应该检查您的 IP,因为我的已更改并收到相同的错误
回答by Hardeep Singh Chhabra
Just add 'localhost' to ALLOWED_HOSTS in settings.py. Then, python manage.py runserver localhost:8000. Run localhost:8000 in your url and it shall work.
只需在 settings.py 中将 'localhost' 添加到 ALLOWED_HOSTS。然后,python manage.py runserver localhost:8000。在您的 url 中运行 localhost:8000 它将起作用。

