27π
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist:
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that userβs password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
13π
If you are bone-headed like me and have used βUSERNAMEβ instead of βUSERβ in your Django database configs in settings.py, make sure you change it to βUSERβ else you will see this same error. Hope this helps someone like me down the road.
- [Django]-When saving, how can you check if a field has changed?
- [Django]-Serving large files ( with high loads ) in Django
- [Django]-Django β Clean permission table
10π
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#ALTER USER yourusername WITH PASSWORD
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
- [Django]-How to get a favicon to show up in my django app?
- [Django]-What does 'many = True' do in Django Rest FrameWork?
- [Django]-Django: Best way to unit-test an abstract model
3π
You can try this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'telusko',
'USER': 'postgres', # not USERNAME, that will cause an error.
'PASSWORD': '1234',
'HOST':'localhost',
}
}
- [Django]-Import Error: No module named django
- [Django]-Django-rest-framework accept JSON data?
- [Django]-Filtering using viewsets in django rest framework
2π
In my case, I had to change
'ENGINE': 'django.db.backends.postgresql_psycopg2',
to
'ENGINE': 'django.db.backends.postgresql',
Hope it helps someone!
- [Django]-Efficient way to update multiple fields of Django model object
- [Django]-Django error when installing Graphite β settings.DATABASES is improperly configured. Please supply the ENGINE value
- [Django]-How to test "render to template" functions in django? (TDD)
2π
Itβs also possible that your PostgreSQL server is not running. Please run next command, to check if postgres is running:
sudo service postgresql status
If not please run it, using:
sudo service postgresql start
Also, you can have wrong port in your settings. To check where Postgres is running use:
sudo netstat -plunt |grep postgres
And after update PORT
in DATABASE
config in Django settings
- [Django]-How to implement followers/following in Django
- [Django]-How to solve "Page not found (404)" error in Django?
- [Django]-How can I programmatically authenticate a user in Django?
1π
For me it was as simple as using capital letters in my db and user name.
It seems that postgres automatically ignores case:
postgres=# CREATE USER MyProjectUser WITH PASSWORD 'password';
is then stored as:
postgres=# \du+
List of roles
Role name | Attributes | Member of | Description
-----------+------------------------------------------------------------+-----------+-------------
myprojectuser | | {} |
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} |
So in my database, this:
DATABASES = {
'default': {
.
.
'USER': 'MyProjectUser',
'PASSWORD': 'password',}}
wasnβt recognized & threw password auth failure error.
- [Django]-How to get username from Django Rest Framework JWT token
- [Django]-Django error: render_to_response() got an unexpected keyword argument 'context_instance'
- [Django]-Django: how to do calculation inside the template html page?
0π
Another reason why this happens is if you have a conflicting version of postgres running. I had one running in docker and another on my system.
systemctl stop postgresql to stop the system version and purge it if youβd rather use only the docker version.
- [Django]-React Error: Target Container is not a DOM Element
- [Django]-Django urlsafe base64 decoding with decryption
- [Django]-What are the differences between django-tastypie and djangorestframework?
0π
Try this for creating the user for Postgres
postgres=# create user username with encrypted password 'password';
Add permissions
postgres=# grant all on database db_name to username;
other useful commands might help
sudo -u postgres psql
\du+ #list of user
\l+ # list of DB
Credits to this article
Note: the database name and the username are always in lowercase, even if you create them with capitals.
- [Django]-Django/DRF β 405 Method not allowed on DELETE operation
- [Django]-Django β How to have a project wide templatetags shared among all my apps in that project
- [Django]-Gunicorn + nginx: Server via socket or proxy?
0π
Wanna do my part as a fellow developer here who got this issue too
You might be following a sometimes dubious "by the book guide" to set up PGSQL with Django. Some of the guides do not require us to write down the HOST
and PORT
in the DATABASES
section. Like this :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'urdb',
'USER': 'your_username',
'PASSWORD': '1234',
'HOST':'localhost',
'PORT':''
}}
I fixed this by :
- Check my actual host and port, in my case, the default port is
5433
- Put
5433
in thePORT
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'urdb',
'USER': 'your_username',
'PASSWORD': '1234',
'HOST':'localhost',
'PORT':'5433'
}}
Et voila! No more authentication issues!
Donβt expect your environment nor codes to know everything! π
- [Django]-Django 2.0 β Not a valid view function or pattern name (Customizing Auth views)
- [Django]-Add Text on Image using PIL
- [Django]-Foreignkey (user) in models
-1π
I had not exactly the same problem cause mine was with docker-compose
, django
but mainly with postgres
in which in steps of building django
project (note deletion of database wasnt an issue) I couldnt migrate
my database so by deleting data\db
folder I attempted to solve it. for more information on my problem Django Postgres docker-compose connection error mainly failed: FATAL: password authentication failed for user foobar ERROR: 2
- [Django]-How to use Faker from Factory_boy
- [Django]-How to create a fixture file
- [Django]-'EntryPoints' object has no attribute 'get' β Digital ocean