Error Django connection to PostgreSQL Peer authentication failed

0 votes

Error I am receiving when I try to get to my Django admin site. I had been using MySQL database no problem. I am new to PostgreSQL, but decided to switch because the host I ultimately plan to use for this project does not have MySQL

OperationalError at /admin/

FATAL:  Peer authentication failed for user "myuser"

Therefore, I figured I could go through the process of installing PostgreSQL, run a syncdb and be all set.

Problem is that I cannot seem to get my app to connect to the database. I can login to PostgreSQL via command line or desktop app that I downloaded. Just not in the script.

Aug 12, 2020 in Python by kartik
• 37,520 points
2,087 views

1 answer to this question.

0 votes

Hello @kartik,

My settings.py did not have a HOST for MySQL database, but I needed to add one for PostgreSQL to work.

In my case, I added localhost to the HOST setting and it worked.

Here is the DATABASES section from my settings.py.

DATABASES = { 
    'default': { 
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '<MYDATABASE>', 
        'USER': '<MYUSER>', 
        'PASSWORD': '<MYPASSWORD>', 
        'HOST': 'localhost', # the missing piece of the puzzle 
        'PORT': '', # optional, I don't need this since I'm using the standard port
    } 
}

Hope it helps!!
Thank you!!

answered Aug 12, 2020 by Niroj
• 82,840 points

Related Questions In Python

0 votes
1 answer

Django Postgresql syncdb error

If you're trying to connect to a ...READ MORE

answered May 27, 2019 in Python by SDeb
• 13,300 points
1,581 views
+1 vote
1 answer

Error:Unable to import path from django.urls

Hello @kartik, You need Django version 2 pip install ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,840 points
11,390 views
0 votes
1 answer

Error "Failed to load tensorflow runtime"

Hello, Try to downgrade protobuf, this worked for ...READ MORE

answered Nov 30, 2020 in Python by Niroj
• 82,840 points
517 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,004 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,985 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,911 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,589 views
0 votes
1 answer

How to set up a PostgreSQL database in Django?

Hello @kartik, Steps that I use: - sudo apt-get ...READ MORE

answered Jun 30, 2020 in Python by Niroj
• 82,840 points
873 views
0 votes
1 answer

How to test an API endpoint with Django-rest-framework using Django-oauth-toolkit for authentication?

Hello @kartik, You should avoid making unneeded API calls, ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,840 points
2,851 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP