title: How to allow postgres login without password prompt on local connection?
body: <p>How do you configure PostgreSQL to allow the default postgres user to login without a password from localhost?</p>
  
  <p>There are several similar questions, such as <a href="https://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge">this</a> and <a href="https://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres">this</a>, but none of the suggestions to modify <code>pg_hba.conf</code> have worked for me. However, based on my understanding of the <code>pg_hba.conf</code> rules, I should be able to accomplish this with either the <code>peer</code> or <code>trust</code> options.</p>
  
  <p>I'm trying to run a command like:</p>
  
  <pre><code>sudo psql --user=postgres --no-password --command="blah;" -h 127.0.0.1
  </code></pre>
  
  <p>If I try this line in my <code>pg_hba.conf</code>:</p>
  
  <pre><code>local   all             postgres                                trust
  </code></pre>
  
  <p>my command fails with the error:</p>
  
  <pre><code>psql: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL on
  FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL off
  </code></pre>
  
  <p>If I tried this line:</p>
  
  <pre><code>local   all             postgres                                peer
  </code></pre>
  
  <p>my command fails with the same error.</p>
  
  <p>How do I fix this?</p>