关于Heroku Django应用程序的Postgres localhost问题

时间:2014-10-14 04:40:33

标签: python django postgresql heroku

我不能为我的生活弄清楚这一点。每当我尝试运行数据库迁移(目前使用South for Django 1.6.5)时,我都会收到此错误:

conn = _connect(dsn, connection_factory=connection_factory, async=async)
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?

我已经尝试了我能想到的每个设置配置。我有一个基本,本地和生产设置文件。在我的生产设置文件中,我甚至从heroku网站上的信息页面复制了数据库字典值,以确保它们匹配。前)

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'd3...k',
    'USER': 'yvg...f',
    'PASSWORD': '...',
    'HOST': '....amazonaws.com',
    'PORT': '5432',
}

}

我没有看到我告诉它寻找localhost的任何人。

1 个答案:

答案 0 :(得分:0)

您是否检查了应用程序以确保设置了DATABASE_URL?它应该指向您尝试使用的数据库(HEROKU_POSTGRESQL_COLOR_URL的各种类型)。然后,使用dj_database_url.config()作为@rajasimon提到。请参阅此处https://devcenter.heroku.com/articles/getting-started-with-python#provision-a-database

相关问题