dropdb utility command prompts for password despite valid .pgpass file in home directory

From: Alan Lin <alin(at)codecademy(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: dropdb utility command prompts for password despite valid .pgpass file in home directory
Date: 2022-06-23 19:21:52
Message-ID: CAHX75vqgnHFU5i39Qikv6U0sM-+h90dd2KBYEW+qbWCVM9SkOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Problem:

I'm trying to use the dropdb utility command in non-interactive mode to
drop an existing database (with active connections) in a test environment,
but it keeps prompting me for the password.

Here's what I'm running with `.pgpass` with valid permissions (0600) and
location (users home directory, though I've also explicitly set the path
using PGPASSFILE envvar). This pass file was validated to work with other
utility commands like pg_dump.

Note: "myserverhost" is not a real host - I've just redacted our actual
hostname for this bug report.

Command:

```
dropdb --host <myserverhost.amazonaws.com> -w <mydbname>
```

Response:

```
dropdb: error: could not connect to database template1: connection to
server at "<myserverhost.amazonaws.com>" (<redacted IP>), port 5432 failed:
fe_sendauth: no password supplied
```

Note the `template1` error despite me passing the correct database name.

To confirm that nothing is wrong with my `.pgpass` file, I ran `pg_dump`
and `pg_restore` and they ran fine (without any assistance of envvars like
PGPASSWORD). `dropdb` also seems to work fine if I provide an explicit
password through the environment.

What I expect to happen:

The command should read from my valid `.pgpass` file and drop the database

Thank you.

*Additional Information*

*Postgres Version:*

psql (PostgreSQL) 13.7 (Debian 13.7-1.pgdg100+1)

*System Information*

On a AWS Ubuntu VM

Output of `lscpu`

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 23
Model: 1
Model name: AMD EPYC 7571
Stepping: 2
CPU MHz: 2199.998
BogoMIPS: 4399.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 64K
L2 cache: 512K
L3 cache: 8192K

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2022-06-23 19:27:34 Re: BUG #17529: SQL Error [57P01]: FATAL: terminating connection due to administrator command
Previous Message Kevin Wolf 2022-06-23 15:58:42 Re: BUG #17529: SQL Error [57P01]: FATAL: terminating connection due to administrator command