postgres peer authentication failed
I'm running into a problem getting the Postgres service set up on a Ubuntu1804 environment. With the attached appveyor.yml, I am attempting to have it create a Postgres database prior to tests running.
-
createdb is failing:
createdb: could not connect to database template1: FATAL: Peer authentication failed for user "postgres"
-
If I ssh into the environment and run createdb in that shell, the command succeeds without error
-
If, in ssh after creating the database, I attempt to psql into Postgres (
psql -d test_db_setup -U postgres -W -h localhost
) with the default username and password documented (postgres, Password12!), I get an auth error:psql: FATAL: password authentication failed for user "postgres"
-
If I then reset the password in Postgres for the postgres user to what I expect it to be, I can then proceed normally
Questions:
-
Why does createdb fail when run from appveyor.yml, but succeed when I ssh to the build instance?
-
Why does the postgres user seem to have different credentials from what is documented?
Thanks for any assistance.
- appveyor.yml 935 Bytes
- appveyor_build_log.txt 1.14 KB
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Wasa Pleshakov on Feb 25, 2019 @ 10:38 PM
You dont have to set variables
PGUSER
andPGPASSWORD
since postgres configured to allow passwordless connections for current userappveyor
.Remove both next lines and it should work:
2 Posted by matt.lewellyn on Feb 26, 2019 @ 05:14 PM
I see, that worked for the
createdb
issue. I would propose updating the documentation at https://www.appveyor.com/docs/services-databases/#postgresql to reflect this, as that indicates using these variables for the command line tools.However, password auth over TCP from the application I am testing still doesn't work. The following SSH session output shows that only if I reset the postgres user's password to the documented password, I can do TCP connection as expected.
3 Posted by Wasa Pleshakov on Feb 26, 2019 @ 10:05 PM
Oh, we don't set the password for postgres user at all on Ubuntu.
The document you refer to was written for Windows and it reflects the state of postgres on Windows.
We will fix both
pg_hba.conf
and password in next ubuntu image update.Meanwhile, you may automate update of phg_hba.conf:
Init stage will execute before starting postgres service.And you may add next line to set password for postgres user:
4 Posted by matt.lewellyn on Feb 27, 2019 @ 04:37 PM
Thank you for the additional configuration - that resolved my problem, and the builds are now chugging along quite well.
matt.lewellyn closed this discussion on Feb 27, 2019 @ 04:40 PM.