PostgreSQL登录适用于本地主机,但不适用于xxxx.compute-1.amazonaws.com

时间:2017-02-21 04:46:32

标签: python django database postgresql database-connection

所以我打开psql终端(在Windows上)。我使用localhost上设置的服务器

登录

但是当我尝试使用我的生产主机登录时:

xxxx.compute-1.amazonaws.com

我收到以下错误:

> psql: FATAL:  password authentication failed for user "postgres"
> FATAL:  no pg_hba.conf entry for host "128.6.37.14", user "postgres",
> database "campus", SSL off

我尝试将它添加到pg_hba.conf中,但没有运气:

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             128.6.37.14/32          trust

知道问题是什么吗?主人是否正确?这是我跑heroku config

时得到的结果

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我假设您正在使用Heroku Postgres,基于PostgreSQL的Heroku数据库即服务,对吗?

如果是这样,您可以使用heroku pg:psql CLI命令connect to your Heroku Postgres database from outside of Heroku

首先,发出以下命令以获取您的Heroku Postgres附加组件名称:

public async Task<ActionResult> UploadAsync()
{
    try
    {
        HttpFileCollectionBase files = Request.Files;
        int fileCount = files.Count;

        if (fileCount > 0)
        {
            for (int i = 0; i < fileCount; i++)
            {
                CloudBlockBlob blob = blobContainer.GetBlockBlobReference(GetRandomBlobName(files[i].FileName));

                blob.Properties.ContentType = files[i].ContentType;
                blob.UploadFromStream(files[i].InputStream);

                // the above 2 lines replace the following line from the downloaded example project:
                //await blob.UploadFromFileAsync(Path.GetFullPath(files[i].FileName), FileMode.Open);
            }
        }
        return RedirectToAction("Index");
    }
}

然后你可以这样做:

heroku pg:info

e.g。

heroku pg:psql <Add-on>