title: Rails db:create failing with Postgres, claiming role doesn't exist when it does
body: <p>I've seen a mountain of questions related to this, but up to now none of the solutions that have worked for others have worked for myself.</p>
  
  <p>presently my attempts to run 'rails db:create' are getting me the following </p>
  
  <pre><code>[ethannicolai@localhost EthansDevcampPortfolio]$ rails db:create --trace EDP_DB_PASSWORD='password1' RAILS_ENV=development
  ** Invoke db:create (first_time)
  ** Invoke db:load_config (first_time)
  ** Execute db:load_config
  ** Execute db:create
  FATAL:  role "EthansDevcampPortfolio" does not exist
  Couldn't create database for {"adapter"=&gt;"postgresql", "encoding"=&gt;"unicode", "pool"=&gt;5, "database"=&gt;"EthansDevcampPortfolio_development", "username"=&gt;"EthansDevcampPortfolio", "password"=&gt;"password1", "host"=&gt;nil}
  rails aborted!
  ActiveRecord::NoDatabaseError: FATAL:  role "EthansDevcampPortfolio" does not exist
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:705:in `rescue in connect'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:88:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:117:in `create'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/railties/databases.rake:27:in `block (2 levels) in &lt;top (required)&gt;'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
  /usr/share/ruby/monitor.rb:214:in `mon_synchronize'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/command.rb:46:in `invoke'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands.rb:16:in `&lt;top (required)&gt;'
  bin/rails:4:in `require'
  bin/rails:4:in `&lt;main&gt;'
  PG::ConnectionBad: FATAL:  role "EthansDevcampPortfolio" does not exist
  /home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `initialize'
  /home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `new'
  /home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `connect'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:88:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:117:in `create'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
  /usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/railties/databases.rake:27:in `block (2 levels) in &lt;top (required)&gt;'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
  /usr/share/ruby/monitor.rb:214:in `mon_synchronize'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
  /home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/command.rb:46:in `invoke'
  /usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands.rb:16:in `&lt;top (required)&gt;'
  bin/rails:4:in `require'
  bin/rails:4:in `&lt;main&gt;'
  Tasks: TOP =&gt; db:create
  </code></pre>
  
  <p>Within my postgres console, when I enter the \du, I get back
      ethansdevcampportfolio | Superuser, No inheritance, Create role, Create DB</p>
  
  <p>I've scrutinized the user name and passwords many many times.</p>
  
  <p>pg_hba.conf looks like</p>
  
  <pre><code>local   all         all                               trust
  
  host    all         all         127.0.0.1/32          trust
  
  host    all         all         ::1/128               trust
  
  host    all         all         0.0.0.0/0         md5(I even tried this at 'trust')
  </code></pre>
  
  <p>config/database.yml looks like</p>
  
  <pre><code># PostgreSQL. Versions 9.1 and up are supported.
  #
  # Install the pg driver:
  #   gem install pg
  # On OS X with Homebrew:
  #   gem install pg -- --with-pg-config=/usr/local/bin/pg_config
  # On OS X with MacPorts:
  #   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
  # On Windows:
  #   gem install pg
  #       Choose the win32 build.
  #       Install PostgreSQL and put its /bin directory on your path.
  #
  # Configure Using Gemfile
  # gem 'pg'
  #
  default: &amp;default
    adapter: postgresql
    encoding: unicode
    # For details on connection pooling, see Rails configuration guide
    # http://guides.rubyonrails.org/configuring.html#database-pooling
    pool: &lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&gt;
  
  development:
    &lt;&lt;: *default
    database: EthansDevcampPortfolio_development
  
    # The specified database role being used to connect to postgres.
    # To create additional roles in postgres see `$ createuser --help`.
    # When left blank, postgres will use the default role. This is
    # the same name as the operating system user that initialized the database.
    username: EthansDevcampPortfolio
  
    # The password associated with the postgres role (username).
    password: &lt;%= ENV['EDP_DB_PASSWORD'] %&gt;
  
    # Connect on a TCP socket. Omitted by default since the client uses a
    # domain socket that doesn't need configuration. Windows does not have
    # domain sockets, so uncomment these lines.
    host:
  
    # The TCP port the server listens on. Defaults to 5432.
    # If your server runs on a different port number, change accordingly.
    #port: 5432
  
    # Schema search path. The server defaults to $user,public
    #schema_search_path: myapp,sharedapp,public
  
    # Minimum log levels, in increasing order:
    #   debug5, debug4, debug3, debug2, debug1,
    #   log, notice, warning, error, fatal, and panic
    # Defaults to warning.
    #min_messages: notice
  
  # Warning: The database defined as "test" will be erased and
  # re-generated from your development database when you run "rake".
  # Do not set this db to the same as development or production.
  test:
    &lt;&lt;: *default
    database: EthansDevcampPortfolio_test
  
  # As with config/secrets.yml, you never want to store sensitive information,
  # like your database password, in your source code. If your source code is
  # ever seen by anyone, they now have access to your database.
  #
  # Instead, provide the password as a unix environment variable when you boot
  # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
  # for a full rundown on how to provide these environment variables in a
  # production deployment.
  #
  # On Heroku and other platform providers, you may have a full connection URL
  # available as an environment variable. For example:
  #
  #   DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
  #
  # You can use this database configuration with:
  #
  production:
    url: &lt;%= ENV['DATABASE_URL'] %&gt;
  #
  production:
    &lt;&lt;: *default
    database: EthansDevcampPortfolio_production
    username: EthansDevcampPortfolio
    password: &lt;%= ENV['EDP_DB_PASSWORD'] %&gt;
  </code></pre>
  
  <p>I'm running out of ideas of places to look. I thought maybe there was a way I unwittingly installed more that one instance of postgres. I mean I'm a noob to all this, so I ran the dnf list installed and I only saw one instance of postgres there.</p>
  
  <p>Any ideas of where to look, what to try or who to ask would be welcomed.</p>