Postgresql install errors on Ubuntu 16.04

I was getting the same error but I realized my problem was that I initially had a role with my username so what I needed to do was to drop that role in postgres and then follow the steps again:

# Postgresql
sudo -u postgres -i
createuser --superuser -Upostgres $(cat /tmp/username)
psql -c “ALTER USER $(cat /tmp/username) WITH PASSWORD ‘password’;”
exit