Re: FastCgi / PostgreSQL: FATAL: Ident authentication fai

From: Matthias(dot)Pitzl(at)izb(dot)de
To: binberati(at)gmail(dot)com, pgsql-admin(at)postgresql(dot)org
Subject: Re: FastCgi / PostgreSQL: FATAL: Ident authentication fai
Date: 2006-10-23 09:00:33
Message-ID: 11EC9A592C31034C88965C87AF18C2A70CFCC0@m0000s61
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hello!

Your problem is that you have the pg_hba.conf set to do an ident
authentication if the connection comes from localhost - this is the default
setting imho.
Your password settings the in the settings.py won't work since your process
will run under the Apache user, nobody or www-data usually. On connect
postgresql will check the ident of this user and this fails.
We use following setting to prevent this:
- connect not on localhost but on the external IP
- set up pg_hba.conf to use say MD5 for connections on the external IP

The difference between a FastCGI environment and your other tests is the
environment. With psql your in a shell with the correct user.
I hope this help.

-- Matthias

> -----Original Message-----
> From: pgsql-admin-owner(at)postgresql(dot)org
> [mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of binberati
> Sent: Wednesday, October 18, 2006 4:35 AM
> To: pgsql-admin(at)postgresql(dot)org
> Subject: [ADMIN] FastCgi / PostgreSQL: FATAL: Ident
> authentication failed for user "user_name"
>
>
> Hi,
>
> I have a strange problem running Django on a GrokThis.net shared
> hosting account:
>
> Environment:
> ------------------------------------------------------
> Apache/2.0.59 (Unix)
> mod_fastcgi/2.4.2
> PostgreSQL 8.1.3
> ------------------------------------------------------
>
>
> settings.py:
> ------------------------------------------------------
> DATABASE_ENGINE = 'postgresql'
> DATABASE_USER = 'user_name'
> DATABASE_PASSWORD = '***'
> ------------------------------------------------------
> or
> ------------------------------------------------------
> DATABASE_ENGINE = 'postgresql_psycopg2'
> DATABASE_USER = 'user_name'
> DATABASE_PASSWORD = '***'
> ------------------------------------------------------
>
>
> Django on FastCgi renders this error:
> ------------------------------------------------------
> Traceback (most recent call last):
> File
> "/home/shared/user_name/django_src/django/template/__init__.py" in
> render_node
> 706. result = node.render(context)
> File
> "/home/shared/user_name/django_src/django/template/__init__.py" in
> render
> 757. return self.encode_output(output) File
> "/home/shared/user_name/django_src/django/template/__init__.py" in
> encode_output
> 739. return str(output)
> File "/home/shared/user_name/django_src/django/db/models/query.py" in
> __repr__
> 97. return repr(self._get_data())
> File "/home/shared/user_name/django_src/django/db/models/query.py" in
> _get_data
> 430. self._result_cache = list(self.iterator()) File
> "/home/shared/user_name/django_src/django/db/models/query.py" in
> iterator
> 170. cursor = connection.cursor()
> File
> "/home/shared/user_name/django_src/django/db/backends/postgres
> ql/base.py"
> in cursor
> 43. self.connection = Database.connect(conn_string)
>
> OperationalError at /
> FATAL: Ident authentication failed for user "user_name"
> ------------------------------------------------------
>
> Surprisingly, I can succesfully connect to the db using either:
>
> - psql - PostgreSQL interactive terminal
> - django-admin.py shell
> - django-admin.py dbshell
> - django development server
> - Navicat PostgreSQL from my own pc using ssh-tunnel
>
> The only circumstance in which I cannot seem to connect to the db is
> using the FastCgi instance, although it is configured to use the same
> settings file as above...
>
>
> [1] Can anybody shed a light on the difference between the FastCgi
> context and the ones mentioned above? I suspect it must have something
> to do with pg_hba.conf... but I can't see the difference between the
> contexts.
>
> [2] How do I resolve this issue? :)
>
>
> Thanks very much in advance!
>
> Best regards,
> bin
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

Browse pgsql-admin by date

  From Date Subject
Next Message Adriaan Joubert 2006-10-23 13:49:13 currval() race condition on server?
Previous Message brian 2006-10-23 07:44:09 Re: How to determine initdb parameters on old database?