django - 如何检查 django 在正在运行的服务器上使用的端口? `manage.py runserver 0.0.0.0:<port>` ,或通过 apache/nginx

标签 django ubuntu port

我需要对已经在服务器中运行的 django 应用程序进行故障排除。我要访问APP URL IP:PORT但我不知道前开发人员用什么端口来运行它。例如:manage.py runserver 0.0.0.0:<port>

是否有可能通过类似的方式检查这个已使用的端口

netstat -ano | grep ...

netstat -ano | grep runserver不提供任何东西。

如果不使用runserver ,我应该如何检查(apache/nginx)?

最佳答案

您确定服务器是使用“runserver”启动的吗?如果使用像 apache 或 nginx 这样的网络服务器,那么您需要查找这些进程名称。


如果使用“runserver”:

选项 1: netstatgrep 用于“python”而不是“runserver”(请参阅​​ this askubuntu answer):

$ sudo netstat -peanut | grep python
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      1000       3645959    28500/python        
tcp        0      0 127.0.0.1:37004         127.0.0.1:39989         ESTABLISHED 1000       3041068    22188/python        
$ 

选项 2: psgrep 用于“runserver”:

$ ps -aux | grep runserver
ralf     28500  2.2  0.4 309672 74184 tty2     Sl+  14:11   0:14 /home/ralf/.venv/bin/python /home/ralf/manage.py runserver
ralf     29199  0.0  0.0  21532  1000 pts/0    S+   14:22   0:00 grep --color=auto runserver
$

关于django - 如何检查 django 在正在运行的服务器上使用的端口? `manage.py runserver 0.0.0.0:<port>` ,或通过 apache/nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59326949/

相关文章:

ruby-on-rails - ubuntu 上的 capistrano 部署错误 - 找不到捆绑程序

ruby-on-rails - 运行包导致无限循环

Unix 套接字编程 : port is not getting unbound after server shutdown

powershell - PowerShell Active Directory 需要打开哪些端口/服务才能正常运行?

python - 如何在中间件中更新 Django HttpRequest 主体

mysql - 我如何使用 django migrations.RunSQL 和 MySQL 删除索引(如果存在)

Django celery : Execute only one instance of a long-running process

django - Django 的 Haystack 是什么?

mysql - 如何在 Ubuntu 12.04 中安装 Toad for MySQL

java - Rack 端口到 Java?