简体   繁体   English

无法访问 http://server_domain_or_IP:8000

[英]cannot acces http://server_domain_or_IP:8000

I am using an AzureVM to host my development API server written in django. There, I cloned my codebase and did all the requirements.txt installation.我正在使用 AzureVM 来托管我在 django 中编写的开发 API 服务器。在那里,我克隆了我的代码库并完成了所有 requirements.txt 安装。 Before executing the manage.py runserver 0.0.0.0:8000 command, I changed the firewall permission rule: sudo ufw allow 8000 .在执行manage.py runserver 0.0.0.0:8000命令之前,我更改了防火墙权限规则: sudo ufw allow 8000 The sudo ufw status commads shows the following result: sudo ufw status commads 显示以下结果:

Status: active

To                         Action      From
--                         ------      ----
Nginx HTTP                 ALLOW       Anywhere                  
8000                       ALLOW       Anywhere                  
OpenSSH                    ALLOW       Anywhere                  
Nginx HTTP (v6)            ALLOW       Anywhere (v6)             
8000 (v6)                  ALLOW       Anywhere (v6)             
OpenSSH (v6)               ALLOW       Anywhere (v6)  

and then I run python3 manage.py runserver 0.0.0.0:8000 .然后我运行python3 manage.py runserver 0.0.0.0:8000

I should be able to see the default django page @ http://SERVER_IP_OR_DOMAIN:8000 But nothing shows.我应该能够看到默认的 django 页面 @ http://SERVER_IP_OR_DOMAIN:8000但没有任何显示。 whereas if I hit http://SERVER_IP_OR_DOMAIN , I can see the NGINX landing page.而如果我点击http://SERVER_IP_OR_DOMAIN ,我可以看到 NGINX 登陆页面。

I am following this blog from digital ocean .我正在关注来自数字海洋的这个博客。

Here is my VM.network rules:这是我的 VM.network 规则: 虚拟机网络规则

How can I fix this?我怎样才能解决这个问题?

I tried to reproduce the same in my environment and got the results like below:我尝试在我的环境中重现相同的内容并得到如下结果:

在此处输入图像描述

To resolve this issue:要解决此问题:

In your virtual machine make sure to Add inbound port Destination port ranges as 8000 like below:在您的虚拟机中,确保将入站端口目标端口范围添加为 8000 ,如下所示:

在此处输入图像描述

Workaround: installed nginx using sudo apt install nginx解决方法:使用sudo apt install nginx

在此处输入图像描述

Install sudo apt-get install python3-venv and create a virtual environment python3 -m venv /home/imran/env<nameof virtual enviroment> and then ls安装sudo apt-get install python3-venv并创建虚拟环境python3 -m venv /home/imran/env<nameof virtual enviroment>然后ls

Now, try to activate your virtual environment source ~/env/xyz/bin/activate现在,尝试激活你的虚拟环境source ~/env/xyz/bin/activate

在此处输入图像描述

Install Django:安装 Django:

pip install Django

在此处输入图像描述

create a Django project which should be on your path by default.创建一个 Django 项目,默认情况下它应该在你的路径上。

django-admin.py startproject  myproject
ls
cd myproject/
ls

在此处输入图像描述

Then vim myproject/setting.py press insert key type your ip address in allowed_hosts like below然后vim myproject/setting.py按插入键在 allowed_hosts 中键入您的 ip 地址,如下所示

在此处输入图像描述

Once you check with your *http://SERVER_IP:8000* got result successfully一旦你检查你的*http://SERVER_IP:8000*成功得到结果

To more in detail refer this link by tony要更详细地参考托尼的这个链接

Set Up Django on Nginx with uWSGI - Tony Teaches Tech使用 uWSGI 在 Nginx 上设置 Django - Tony Teaches Tech

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到 http://127.0.0.1:8000/ 的 Django 服务器 - Unable to connect to django server at http://127.0.0.1:8000/ 无法打开http:// localhost:8000 /,但是在公共ip ngnix Django中打开 - Not able to open http://localhost:8000/ but opening in public ip ngnix Django 如何从 http://127.0.0.1:8000 重定向到 http://127.0.0.1:8000/login/ 同时启动 ZEF0F93C83E371634AB 开发服务器? - How to redirect from http://127.0.0.1:8000 to http://127.0.0.1:8000/login/ while starting the Django development server? 无法访问Django服务器,请访问http://127.0.0.1:8000/ - Can't access the Django server at http://127.0.0.1:8000/ 我无法访问http:// localhost:8000 / accounts / profile - I cannot access http://localhost:8000/accounts/profile 服务器在 python django 中的 http://127.0.0.1:8000/admin/ 处停止 - Server stops at http://127.0.0.1:8000/admin/ in python django Django - 为dev web服务器显示404页面(http://127.0.0.1:8000/) - Django - 404 page displayed for dev web server (http://127.0.0.1:8000/) 在http://127.0.0.1:8000/上设置Python开发服务器时出现问题 - Problems setting up Python development server at http://127.0.0.1:8000/ TemplateDoesNotExist 在 http://127.0.0.1:8000/ - TemplateDoesNotExist at http://127.0.0.1:8000/ 在云上部署Django应用程序,但甚至无法访问ip_address:8000 - Deploy Django Application on Cloud, but even cannot get access to ip_address:8000
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM