#19090 closed Bug (fixed)
Change to PostgreSQL notes for Django 1.4
Reported by: | Rohaq | Owned by: | Lebedev Ilya |
---|---|---|---|
Component: | Documentation | Version: | 1.4 |
Severity: | Normal | Keywords: | postgresql setup |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Hi,
You might want to add a note for the following page under PostgreSQL:
https://docs.djangoproject.com/en/1.4/ref/databases/
I'm running PostgreSQL 9.1 locally, and found that Django was unable to connect to the database when the 'HOST' value was left as an empty string, resulting in the following error when running python manage.py syncdb
:
psycopg2.OperationalError: FATAL: Peer authentication failed for user
After some searching, I found the following solution on StackOverflow: http://stackoverflow.com/a/8232004/733402
Setting it to localhost
rather than an empty string (as suggested by the inline comments in the config file) fixed the issue. You might want to consider adding this to the documentation so that other users can more easily work around the same issue.
Cheers!
-R
Attachments (1)
Change History (9)
comment:1 by , 12 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
-1 to set localhost by default.
Very roughly, here is what we could add:
"By default (empty HOST), the connection to the database is done through UNIX domain sockets ('local' lines in pg_hba.conf). If you want to connect through TCP sockets, set HOST to 'localhost' or '127.0.0.1' ('host' lines in pg_hba.conf). On Windows, you should always define HOST, as UNIX domain sockets are not available."
comment:4 by , 12 years ago
Owner: | changed from | to
---|
by , 12 years ago
Attachment: | ticket_19090.diff added |
---|
comment:5 by , 12 years ago
Has patch: | set |
---|
comment:6 by , 12 years ago
Status: | new → assigned |
---|
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The problem here is that psycopg2's default is a UNIX socket not an IP connection to localhost, which is what the comment in settings might suggest. I think it would be better to fix the settings.py template and/or change the driver to pass 'localhost' to psycopg2 by default.