PostgreSQL: Using the .pgpass file

I have been reading up on the .pgpass file, but I can’t get it working for me.

My .pgpass file looks something like this:

127.0.0.1:5432:accounts:fred:p@55w0rd 

I set the privilege to 0600 (this is on CentOS Linux) and try:

psql 

Where I get the message:

psql: error: FATAL: database "…" does not exist

where is my user name.

I can successfully connect if I use:

psql -u … -d accounts 

so I don’t think my .pgpass file is doing its job.

How can I get it to work?