<p>我最近也遇到了同样的问题,我找到了解决这个问题的办法。</p>
<p><strong>系统:</strong></p>
<ol>
<li>我有一个应用程序服务器(安装了这些包<code>python</code>、<code>django</code>、<code>psycopg2</code>和<code>postgres client 9.6.1</code>(<code>postgresql-9.6.1.tar.gz</code>)),例如<code>ip address 10.0.0.1</code>(私有地址)。</li>
<li>和AWS postgres RDS服务器“<code>aws_rds_host_name</code>”或任何数据库IP地址。</li>
</ol>
<p><strong>错误:</strong></p>
<p><code>django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host</code><code>"10.0.0.1", user "your_user", database "your_db", SSL off</code></p>
<p><strong>解决方案:</strong></p>
<p>在应用服务器<code>10.0.0.1</code>中安装<code>postgres client 9.6.1</code>源包时,我们必须传递一个参数“<code>--with-openssl</code>”。我建议删除现有的<code>postgres client</code>,并按以下步骤安装。</p>
<ol>
<li>下载<code>postgres client source package 9.6.1</code>(<code>postgresql-9.6.1.tar.gz</code>)</li>
<li>解开包裹<code>postgresql-9.6.1.tar.gz</code>。</li>
<li><code>./configure --prefix="your_preferred_postgres_path_if_needed" --with-openssl (this '--with-openssl'</code>参数对于消除该错误非常重要)</li>
<li>制造</li>
<li>进行安装</li>
<li>成功安装后,当我们使用<code>psycopg2</code>运行django项目时,不会发生该错误。</li>
</ol>
<p>我希望这个解决方案能帮助别人。</p>