I'm trying to learn web development with Django and I was following this guide to do so.
Everything works fine until I run the following:
python manage.py makemigrations
I get this error message:
password authentication failed for user "myprojectuser"
I have checked and rechecked many times and the password is correct in the settings.py file.
Below is the content of the file (settings.py):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myproject',
'USER': 'myprojectuser',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
}
}
I am using postgreSQL 9.5, python 2.7, and Django 1.10.
From your guide:
"
By default, Postgres uses an authentication scheme called "peer authentication" for local connections. Basically, this means that if the user's operating system username matches a valid Postgres username, that user can login with no further authentication.
"
so I am guessing that if you will create a user for your DB with the same name as your OS local username it might work :)
In case the "DATABASES" setting you showed are not the one you actually use - check if the "NAME" and the "USER" are in lowercase
Related
I am super beginner, but want to learn super fast building web application.
I am right now developing an Income-Expense web app on Django Framework (Python, js and Ajax).
I am now stuck with the server and get different errors. Anyone can support me ?
ERROR
"django.db.utils.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied"
I think I shut down everything not properly and when a came back my virtual environment was not working.
Thank You
Don't know what to try more
To resolve the issue, make sure that you have the correct credentials to access your PostgreSQL database. You may need to update the database settings in your Django settings.py file to include the correct database name, username, password, host, and port information.
for example
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydatabase',
'USER': 'mydatabaseuser',
'PASSWORD': 'mypassword',
'HOST': 'localhost',
'PORT': '5432',
}
}
I am hosting a postgresql database on AWS using the RDS service. I am trying to connect the django project to the aws database using the settings.py file in the django project. I keep getting the following error:
connection to server at "database-1.xxxxxx.us-east-1.rds.amazonaws.com" (xx.xxx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user "local_user"
This error is unexpected because it should not be trying to authenticate the local_user as this is the user for my local postgres server, it should be trying to authenticate the user for the hosted database, which is completely different.
This is what my settings file looks like:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DATABASE_NAME'),
'USER': os.environ.get('DATABASE_USER'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
'HOST': "database-1.xxxxxx.us-east-1.rds.amazonaws.com",
'PORT': 5432
}
}
I can't figure out what the issue seems to be. Any help will be appreciated!
I named the environment variable wrong so USER was none!
i have been struggling to connect my django web app to a PostgreSQL instance which I set up inside my gcloud account for testing purposes.
I have done the following DB configs in settings.py in Django:
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'instance connection name from gcloud',
'USER' : 'postgres',
'PASSWORD': 'passsss',
'HOST': 'ip-address',
'PORT': '5432',
}
}
the error that I receive in Django after trying to migrate is :
django.db.utils.OperationalError: FATAL: database "..instance connection name from gcloud.." does not exist
I have tried creating a new database "django" and adding it to the NAME with:. This did not work as well. I have also configured in gcloud connections my own computer IP as an authorized network
Normally if I use service like elephantsql it works fine.
Any help would be appreciated. Thanks!
From what I understood from your post, is that you wish to connect from your local pc to a Cloud SQL PostgreSQL instance.
I see that you seem to be following the official documentation already, as you mentioned that you added your IP to authorized networks in order to be able to connect externally.
The cause of your error seems to be due to the format of the NAME parameter.
Are you passing it in this format?
PROJECT:ZONE:INSTANCENAME
Here you have all the available options on how to connect externally to a Cloud PostgreSQL instance.
And here you have the documentation of the requirements to connect an external application to a Cloud SQL PostgreSQL instance.
ok finally after a lot of research and wasting couple of hours I managed to find Django configs in digital ocean docu... pretty weird
This works:
'''
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'my_django_db',
'USER' : 'user1',
'PASSWORD': 'pass',
'HOST': 'ipv4',
'PORT': '',
}
}
'''
I've deploy a django app on EBS http://djangosample.elasticbeanstalk.com/
The 'It worked' message shows up fine in the browser. However I just can't login to /admin, it just loads and does nothing. The localserver http://127.0.0.1:8000 works with the same credentials
Only changes I've made in settings is changing the default database to postgres.
Any ideas?
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> 'NAME': 'postgres',
> 'USER': 'username',
> 'PASSWORD': 'password',
> 'HOST': 'sampledjangoapppostgresql.cmipujlbivbk.ap-southeast-2.rds.amazonaws.com',
> 'PORT': '5432',
> } }
I know you mentioned that you only changed db, but for me this was the problem.
I applied migrations and created a superuser on my ebs. Whenever I tried to login nothing happend, but when I used wrong credentials I got an error. So I assumed my db was setup correctly and had a record for my admin user. I used a seperate production settings file in which I had SESSION_COOKIE_SECURE = True (because django docs recommend this in production)." However I guess this failed the login, because I am not using https yet, but I am not entirely sure. After setting this value to false I could login to my admin panel. Hope this works for someone.
I am new to django.I am using eclipse IDE and my OS is windows 7.I am trying to use postgre sql.My model page is like this:.My settings page is like this:.When I try to type python manage.py sql Mystudent where Mystudent is my app,It shows operational error:fe_sendauth: no password supplied.So when I entered user name as test and password as password it shows operational error:password authentication failed for user 'test'.Please help me.
You should specify host and port in your settings.py file. If you are running postgresql locally it will be:
'HOST': 'localhost',
'PORT': '5432',
Edit
Also note that mydb.db is not a valid database name for postgres.