Drone Server cannot connect to AWS Postgres RDS database

I’m looking into moving my team from Jenkins to Drone. We have a Postgres RDS instance with a few DBs that we use for our internal tools and utilities. I created a new db and role for Drone on this RDS instance. From the ec2 instance where I’m setting up the drone server, and using the same connection string as what I’ve put in the drone config, I can connect to my drone db via psql, but when I try to spin up the drone server, I get the following:

pq: Could not detect default username. Please provide one explicitly.

Any idea what’s up here? Again, I’ve confirmed that it’s not a networking issue or a connection string formatting issue, as the db is reachable via psql.

I would start with your connection string. Are you missing a database username or is there any other configuration parameters you need to add? You can learn more about the postgres connection string here:

You might also have luck posting this error message to Stackoverflow and tagging with Postgresql (https://stackoverflow.com/questions/tagged/postgresql) since this is likely Postgres-specific. There is no database code in Drone per-se, we just pass the connection string unmodified to official Postgres driver.

also someone posted a similar issue and error message here: https://stackoverflow.com/questions/37753055/postgres-error-running-query-on-database-could-not-detect-default-username

So the connection string works with psql. It looks like the error is being thrown here: https://github.com/lib/pq/blob/90697d60dd844d5ef6ff15135d0203f65d2f53b8/user_posix.go

Basically, in the container’s environment, pq wasn’t able to determine a user. For anyone else stumbling across this: the fix was to pass “USER” as an environment variable from the docker-compose.yml file. I.e.: