'(psycopg2.OperationalError) FATAL: password authentication failed for user "myuser" FATAL: password authentication failed for user "myuser"

I am trying to build a simple web app using flask and PostgreSQL. I was using SQLALchemy and psycopg2 to complete the task but I got stuck at this error for a long time. I have my configuration set as follows:

app.config['SQLALCHEMY_DATABASE_URI'] =  "postgresql://myuser:c2yQdn3e@localhost:5432/hello"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)

My database name was "hello" and my user name is "myuser". I have even entered the password correctly but still it is showing this error. I have looked for a lot of solution on the net and tried everything but I am still getting this error. My pg_hba.conf file looks like this

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     md5
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

Thanks a lot in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source