django网站工作,但是django manage.py无法连接到db

时间:2017-08-02 16:49:32

标签: django postgresql

我正在尝试运行django迁移来更新我的数据库,但“manage.py migrate”无法连接到我的postgresql数据库。奇怪的是:我的django网站(完全相同的代码)正在工作,包括连接数据库。

错误讯息:

psycopg2.OperationalError: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.xxxxxx"?

django.db.utils.OperationalError: could not connect to server: No such file or directory 
        Is the server running locally and accepting 
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL

1 个答案:

答案 0 :(得分:-1)

解决方法:将HOST变量更改为localhost或127.0.0.1。

请参阅:https://community.webfaction.com/questions/21072/django-website-working-but-django-managepy-cannot-connect-to-db