完整報錯如下:
django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
#-----------------------------------------------------------------------------------------------
根據5432可知,使用的是PostgreSQL數據庫.
所以需要檢查django中連接postgres的用戶名和密碼是否和實際數據庫的連接用的用戶名和密碼是否一致.
另外需要檢查該數據庫是否存在,如果不存在,需要建立.