Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#19090 closed Bug (fixed)

Change to PostgreSQL notes for Django 1.4

Reported by: Rohaq Owned by: Melevir
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



You might want to add a note for the following page under PostgreSQL:

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 syncdb:

psycopg2.OperationalError: FATAL:  Peer authentication failed for user

After some searching, I found the following solution on StackOverflow:

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.



Attachments (1)

ticket_19090.diff (915 bytes) - added by Melevir 4 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 4 years ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Bug

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 template and/or change the driver to pass 'localhost' to psycopg2 by default.

comment:2 Changed 4 years ago by lrekucki

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by claudep

-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 '' ('host' lines in pg_hba.conf). On Windows, you should always define HOST, as UNIX domain sockets are not available."

comment:4 Changed 4 years ago by Melevir

  • Owner changed from nobody to Melevir

Changed 4 years ago by Melevir

comment:5 Changed 4 years ago by Melevir

  • Has patch set

comment:6 Changed 4 years ago by Melevir

  • Status changed from new to assigned

comment:7 Changed 4 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 249c3d730e632b3c5b8c2bf5e6e871d61df15c6c:

Fixed #19090 - Added PostgreSQL connection note.

Thanks Melevir for the patch.

comment:8 Changed 4 years ago by Tim Graham <timograham@…>

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