Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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)

ticket_19090.diff (915 bytes ) - added by Lebedev Ilya 12 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Łukasz Rekucki, 12 years ago

Type: UncategorizedBug

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.

comment:2 by Łukasz Rekucki, 12 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Claude Paroz, 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 Lebedev Ilya, 12 years ago

Owner: changed from nobody to Lebedev Ilya

by Lebedev Ilya, 12 years ago

Attachment: ticket_19090.diff added

comment:5 by Lebedev Ilya, 12 years ago

Has patch: set

comment:6 by Lebedev Ilya, 12 years ago

Status: newassigned

comment:7 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In 249c3d730e632b3c5b8c2bf5e6e871d61df15c6c:

Fixed #19090 - Added PostgreSQL connection note.

Thanks Melevir for the patch.

comment:8 by Tim Graham <timograham@…>, 12 years ago

In 26e0651c42a70104d237b5433970158d27b244dc:

[1.5.X] Fixed #19090 - Added PostgreSQL connection note.

Thanks Melevir for the patch.

Backport of 249c3d730e from master

Note: See TracTickets for help on using tickets.
Back to Top