Code

Opened 19 months ago

Closed 18 months ago

Last modified 18 months 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

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 Melevir 18 months ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 19 months 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 settings.py template and/or change the driver to pass 'localhost' to psycopg2 by default.

comment:2 Changed 19 months ago by lrekucki

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 19 months 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 '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 Changed 18 months ago by Melevir

  • Owner changed from nobody to Melevir

Changed 18 months ago by Melevir

comment:5 Changed 18 months ago by Melevir

  • Has patch set

comment:6 Changed 18 months ago by Melevir

  • Status changed from new to assigned

comment:7 Changed 18 months 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 18 months 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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.