这可能是一个非常基本的问题。我通过SSH连接到我的虚拟Ubuntu服务器并启动在localhost上运行的django webserver:
Downloading/unpacking django
Downloading Django-1.9.5-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
April 13, 2016 - 14:16:19
Django version 1.9.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Ubuntu服务器有一个静态IP [x.xxx.xxx.xxx]所以从另一台网络上的另一台机器上我尝试使用该静态IP地址在浏览器中访问上述网站:
x.xxx.xxx.xxx:8000
但我明白了:
This site can’t be reached
x.xxx.xxx.xxx refused to connect.
ERR_CONNECTION_REFUSED
所以我假设我无法访问这样的网站,即使主机有外部/静态IP地址,也只能在主机上使用?
修改
答案也在: https://docs.djangoproject.com/en/1.9/intro/tutorial01/#the-development-server
python manage.py runserver 0.0.0.0:8000