{"word_count": 170, "character_count": 1543}
By default, postgres allow only local connections and and uses peer authentification to access the databases. In some cases this provoke the error message "FATAL: Peer authentication failed for user "postgres"This is an explanation how to configure postgres to ask for encrypted password and allow remote connections.Change password for rootuser "postgres"Connect to the default database with user postgressudo -u postgres psql template1Set the password for user postgresALTER USER postgres with encrypted password 'yourpassword';Exit (ctrl + d)Config your postgres to allow remote access and to ask for passwordsGet your IPcurl ipinfo.io/iphere 172.168.0.1Find postgresql.conffind / -name "postgresql.conf"here /etc/postgresql/10/main/postgresql.confEdit the filesudo vim /etc/postgresql/10/main/postgresql.confReplace#listen_addresses = 'localhost'Withlisten_addresses = '*'Find pg_hba.confsudo find / -name "pg_hba.confhere /etc/postgres/10/main/pg_hba.confEdit the filesudo vim /etc/postgresql/10/main/pg_hba.confChange lineslocal    all    postgres              peerlocal    all    all                   peerTolocal    all    postgress             md5local    all    all                   md5And addhost    all    all    172.168.0.1/32  md5Restart the databasesudo /etc/init.d/postgresql restartCheck, if it workedpql -U postgresExit (ctrl + d)Create user and databaseCreate user with linuxusernamesudo createuser -U postgres -d -e -E -l -P -r -s $USERCreate databasecreatedb mynewdatabaseYou can now remote connect to your database&#160;