简体   繁体   English

Django fe_sendauth:未提供密码错误,无法连接到 postgres 数据库

[英]Django fe_sendauth: no password supplied error, unable to connect to postgres database

I am trying to provision a server with a django applciation with postgresql as its backend.我正在尝试使用 django 应用程序配置服务器,并将 postgresql 作为其后端。 After installing the required packages, database and environment when I try to run migrations, I get the following error当我尝试运行迁移时安装所需的包、数据库和环境后,出现以下错误

Traceback (most recent call last):
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/base/base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: fe_sendauth: no password supplied


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
 ====
 ommitting some lines
 ====
    connection = Database.connect(**conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: fe_sendauth: no password supplied

I confirmed that the relevant DATABASE setting required for django are present:我确认存在 django 所需的相关DATABASE设置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'HOST': 'localhost',
        'NAME': DATABASE_NAME,
        'USER': DATABASE_USER,
        'password': DATABASE_PASSWORD
    }
}

I am not sure why this error is happening because this is the same setup I use on my local machine and it works.我不确定为什么会发生此错误,因为这与我在本地计算机上使用的设置相同,并且可以正常工作。 To confirm that there aren't any issues with my pg_hba.conf I started from a fresh installation.为了确认我的pg_hba.conf没有任何问题,我从全新安装开始。 The config hasn't been modified in any way and the application user has the required privileges on the application database.配置没有以任何方式修改,应用程序用户对应用程序数据库具有所需的权限。

设置必须大写 - 尝试将其更改为'PASSWORD'

The key name 'password' should be in uppercase 'PASSWORD' .密钥名称'password'应该是大写的'PASSWORD' Also instead of defining password as global variable DATABASE_PASSWORD , you can use .bashrc file to save secure information and can fetch in settings.py like os.environ['DATABASE_PASSWORD']另外,不是将密码定义为全局变量DATABASE_PASSWORD ,您可以使用 .bashrc 文件来保存安全信息,并且可以像os.environ['DATABASE_PASSWORD']一样在settings.py 中获取

使您的 HOST 变量为空

'HOST': '',

OperationalError: fe_sendauth: no password supplied OperationalError: fe_sendauth: 没有提供密码

you should change password to uppercase 'PASSWORD'您应该将密码更改为大写的“PASSWORD”

In using Django,ensure you have a .env file and configure properly your .postgres and .django envs esp provide Database URL in your .postres or in .env file as such:在使用 Django 时,确保你有一个 .env 文件并正确配置你的 .postgres 和 .django envs esp 在你的 .postres 或 .env 文件中提供数据库 URL,如下所示:

DATABASE_URL=psql://postgres:yourpassword@127.0.0.1:5432/databasename
POSTGRES_HOST=*
POSTGRES_PORT=5432
POSTGRES_DB=tutor
POSTGRES_USER=postgres
POSTGRES_PASSWORD=yourpassword
DJANGO_ALLOWED_HOSTS=['.herokuapp.com', 'localhost', '127.0.0.1', '[::1]', '0.0.0.0']
# DJANGO_DEBUG=False # disable debugging on production
DJANGO_DEBUG=False # disable debugging if hosts list is not empty

For more info on environmental variables please refer to: # .env using django-environ有关环境变量的更多信息,请参阅:# .env using django-environ

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS-DJANGO-格式错误:OperationalError:fe_sendauth:未提供密码 - AWS - DJANGO - Error in formatting: OperationalError: fe_sendauth: no password supplied 使用带有Postgres引擎的AWS Aurora数据库收到“ fe_sendauth:未提供密码”错误,但仅在执行单元测试时出现 - Receiving 'fe_sendauth: no password supplied' error using AWS Aurora database with Postgres engine, but only when performing unit tests Django 4 使用密码文件连接到 Postgresql:“fe_sendauth:未提供密码” - Django 4 connection to Postgresql using passfile: "fe_sendauth: no password supplied" PostgreSQL错误-psql:fe_sendauth:未提供密码 - PostgreSQL Error - psql: fe_sendauth: no password supplied fe_sendauth:Composer 中没有提供密码 - fe_sendauth: no password supplied in Composer 将postgres作为Docker服务运行时,“psql:fe_sendauth:没有提供密码” - “psql: fe_sendauth: no password supplied” when running postgres as a Docker service django.db.utils.OperationalError:fe_sendauth:迁移 django 应用程序时未提供密码 - django.db.utils.OperationalError: fe_sendauth: no password supplied when migrating django app psycopg2.OperationalError:fe_sendauth:未提供密码 - psycopg2.OperationalError: fe_sendauth: no password supplied SQLAlchemy (psycopg2.OperationalError) fe_sendauth:未提供密码 - SQLAlchemy (psycopg2.OperationalError) fe_sendauth: no password supplied Python 和 Postgresql:OperationalError:fe_sendauth:未提供密码 - Python and Postgresql: OperationalError: fe_sendauth: no password supplied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM