无法在Django TCP/IP连接上运行服务器?

2024-09-30 08:18:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经从django、whitenoise等下载了所有软件包,错误还在继续。
cmd与env和triyng一起运行,以推动我仍然处于相同的错误中

我正在尝试使用本地主机运行我的服务器,结果:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\psycopg2\__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Domestico\anaconda3\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
    self.check_migrations()
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
    with self.connection.cursor() as cursor:
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Domestico\Documents\GitHub\venv\lib\site-packages\psycopg2\__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?```

Tags: djangoinpyselfgithubvenvlibpackages
1条回答
网友
1楼 · 发布于 2024-09-30 08:18:38

你能给我们一些更详细的信息吗,比如你正在运行什么命令来启动你的服务器,你是想从同一台计算机上查看网页还是想远程连接到它

您是否尝试过使用此python manage.py runserver运行服务器,然后尝试连接到它

您使用端口5432是否有任何原因,因为默认值为8000,所以最好在更改端口之前先使其工作

相关问题 更多 >

    热门问题