为什么Internet Explorer不能访问我的Django开发服务器,它可以从外部访问(也就是说,不是在本地主机上?)

时间:2022-10-11 00:33:28

I've been tasked by my programming teacher to learn Django. However, I need to code on a command line linux box and therefore cannot access the web page from said linux box.

我的编程老师让我学习Django。但是,我需要在命令行linux box上编写代码,因此无法从该linux box访问web页面。

To test, I need to host it on the local IP of the computer rather than localhost. I’m currently running the Django development server using this command:

要进行测试,我需要将它托管在计算机的本地IP上,而不是本地主机上。我现在使用这个命令运行Django开发服务器:

python manage.py runserver 0.0.0.0:8000

Firefox and Chrome can access the development server at the Linux box’s IP address, but Internet Explorer can’t.

Firefox和Chrome可以通过Linux box的IP地址访问开发服务器,但Internet Explorer不能。

4 个解决方案

#1


7  

Unfortunately (I am said teacher), I can't provide a linux host - only a linux server and a windows host to do development on.

不幸的是(我是老师),我不能提供linux主机——只能提供linux服务器和windows主机进行开发。

He's actually running the web server correctly, with the command provided by Paul. But for some reason, it's only visible in Firefox/Chrome, IE just provides a generic "Webpage cannot be displayed"

实际上,他正在正确地运行web服务器,使用Paul提供的命令。但由于某些原因,它只能在Firefox/Chrome中可见,IE只提供了一个通用的“无法显示网页”

But this problem can be solved by using the entire address: http:// isn't optional like it is in Chrome and Firefox.

但是这个问题可以通过使用整个地址来解决:http://不是可选的,就像在Chrome和Firefox中一样。

#2


5  

When you run the development server, you can make it available on the local network by specifying the IP address 0.0.0.0 for it, like this:

当您运行开发服务器时,您可以通过为其指定IP地址0.0.0.0.0.0,使其在本地网络上可用,如下所示:

python manage.py runserver 0.0.0.0:8000

If your Linux box’s local IP address is e.g. 192.168.1.37, you’d access the development server at:

如果您的Linux box的本地IP地址是192.168.1.37,那么您应该访问以下的开发服务器:

http://192.168.1.37:8000

#3


1  

Setup nginx to listen on a public port and proxy all of the requests to the django runserver.

设置nginx监听公共端口并代理所有对django runserver的请求。

#4


1  

You need to specify the IP clearly in the command line like this in order to let other clients to access. You also have to enable the port 8000 in the firewall:

您需要像这样在命令行中明确地指定IP,以便让其他客户端访问。您还必须在防火墙中启用端口8000:

python manage.py runserver 192.168.1.37:8000

#1


7  

Unfortunately (I am said teacher), I can't provide a linux host - only a linux server and a windows host to do development on.

不幸的是(我是老师),我不能提供linux主机——只能提供linux服务器和windows主机进行开发。

He's actually running the web server correctly, with the command provided by Paul. But for some reason, it's only visible in Firefox/Chrome, IE just provides a generic "Webpage cannot be displayed"

实际上,他正在正确地运行web服务器,使用Paul提供的命令。但由于某些原因,它只能在Firefox/Chrome中可见,IE只提供了一个通用的“无法显示网页”

But this problem can be solved by using the entire address: http:// isn't optional like it is in Chrome and Firefox.

但是这个问题可以通过使用整个地址来解决:http://不是可选的,就像在Chrome和Firefox中一样。

#2


5  

When you run the development server, you can make it available on the local network by specifying the IP address 0.0.0.0 for it, like this:

当您运行开发服务器时,您可以通过为其指定IP地址0.0.0.0.0.0,使其在本地网络上可用,如下所示:

python manage.py runserver 0.0.0.0:8000

If your Linux box’s local IP address is e.g. 192.168.1.37, you’d access the development server at:

如果您的Linux box的本地IP地址是192.168.1.37,那么您应该访问以下的开发服务器:

http://192.168.1.37:8000

#3


1  

Setup nginx to listen on a public port and proxy all of the requests to the django runserver.

设置nginx监听公共端口并代理所有对django runserver的请求。

#4


1  

You need to specify the IP clearly in the command line like this in order to let other clients to access. You also have to enable the port 8000 in the firewall:

您需要像这样在命令行中明确地指定IP,以便让其他客户端访问。您还必须在防火墙中启用端口8000:

python manage.py runserver 192.168.1.37:8000