WebFaction
Community site: login faq

Tried to run some unit tests on my django app last night, and found that it would let me create the test database that I needed. After some googling, I found this:

http://forum.webfaction.com/viewtopic.php?id=3592

After making those modifications in the Django code, I tried it again. But this time I ran into the

psycopg2.OperationalError: FATAL: no pg_hba.conf entry for host "[local]", user "xxxxxxx", on database "xxxxxxx_test".

In my settings.py, I have tried a bunch of combinations changing the USER, NAME, TEST_NAME, and even TEST_USER (even though the Django docs say that it is only an Oracle parameter)

Here is my settings.py code: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'xxxxxxxx',
'TEST_NAME':'xxxxxxx_test', 'USER': 'xxxxxxxx_test', # Have tried both xxxxxxxx and xxxxxxxx_test 'PASSWORD': 'yyyyyyyy',
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. }

Is there something I'm not seeing?

Thanks, Tino

asked 13 Jan '11, 10:11

oberoc
111
accept rate: 0%


What database and username are you using? You have to be sure to use the database name as the username.

permanent link

answered 13 Jan '11, 10:53

aaronh ♦♦
1.3k3
accept rate: 34%

You should not hack Django to make this work, but install your own instance of PostgreSQL. Otherwise you will have to re-hack Django each version update and in new ways, which is why the above instructions no longer work.

permanent link

answered 20 Jan '11, 15:01

johns
5.4k312
accept rate: 23%

The error message states that the credentials presented are not authorised in postgresql's pg_hba.conf allow access to the database. So it's not a question of hacking anything, you're just not presenting the right credentials to gain access to your database.

I'd triple-check your database name/username/password first.

I created a postgresql database named "username_myproj" with user "username_myproj" (also), and then I set a password. My settings look something like...

DATABASE_NAME = 'username_myproj'
DATABASE_USER = 'username_myproj'
DATABASE_PASSWORD = 'password'
DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_HOST = ''
DATABASE_PORT = ''

I didn't bother with the more recent dictionary style declarations.

permanent link

answered 20 Jan '11, 17:05

johnm
113
accept rate: 0%

This can also be caused if the DB server is unreachable on the network. For example, I had to double check that I was actually connected to my network when I first experienced this error. After which I went through my firewall settings and discovered that python was actually being blocked by windows by default.

Normally there's a popup that asks you if you want to allow application X to be accessible on public/private networks, but that didn't occur for python for some reason.

permanent link

answered 21 Nov '11, 21:59

Kreychek
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×84
×9
×1

question asked: 13 Jan '11, 10:11

question was seen: 5,936 times

last updated: 21 Nov '11, 21:59

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM