Hi , i tried to connect avien cloud postgresql using drogon orm c++, gettaing below errors
ERROR !!!Pg connection failed: FATAL: no pg_hba.conf entry for host {HOST}, user {USER}, database {DB_NAME}, no encryption
even i am providing correct postgresql credential. and my IP address allowlist set to 0.0.0.0 , allowed for all IP’s.
Note : {HOST} in the error → is pointing to host where the app is hosted.
i think this error is related to pg_hba.conf , and we dont have access this file from cloud.
how to make sure that our app hosted ip is available in pg_hba.conf , or how can we short out these types of access problems , its very basic errors, Avien engineering must resolve long back , still this types of error is coming.
Are you sure you can use “no encryption” in your connection method? I would be surprised as “All connections to PostgreSQL are encrypted and protected with TLS.”.
Perhaps you need to set sslmode to require in the application (or a higher value, but you must use the provided ca.pem to verify the identity of the server).
i have tested with below command from the app-hosted machine ,
~$ ping {HOST} → working fine
~$ telent {HOST} {PORT} → working fine
connStr = “dbname=db1 user={USER} password={PASS} host={HOST} port=1234 sslmode=require”;
still getting below error
ERROR Connection with Postgres could not be established
This might be an issue with providing the wrong credentials to your connStr.
The deafault database name should be defaultdb
and the default user should be avnadmin
. Try connecting with those and the port listed in the Aiven console first and see if you still have errors.
I am using the same credential provided in the avien console. i am able to connect with DBeaver with credentials , but not using drogon c++.
Can you share the exact Drogon C++ code block or file you’re using to connect as well as the connection details themselves? (Leaving out the password of course).
auto clientPtr = DbClient::newPgClient("dbname=defaultdb user=avnadmin password={PASSWORD} host={HOST} port=22389 sslmode=require",1);
if(clientPtr)
std::cout<<"DB client is created successfully."<<std::endl;
else
std::cout<<"DB client is not created."<<std::endl;
std::cout<<"Connection string is "<<clientPtr->connectionInfo()<<std::endl;
reference for more details (not able to send link)-> go to github and search → /drogonframework/drogon/blob/a3b4779540831cb8c03addb591ced3080b488917/orm_lib/src/postgresql_impl/test/test1.cc
log on aiven console
[testservice-1]
2025-01-21T09:07:12.699774
[postgresql-16]
[12-1] pid=838567,user=avnadmin,db=defaultdb,app=[unknown],client=[local] LOG: connection authorized: user=avnadmin database=defaultdb application_name=management-agent
[testservice-1]
2025-01-21T09:07:12.702924
[postgresql-16]
[13-1] pid=838567,user=avnadmin,db=defaultdb,app=management-agent,client=[local] LOG: disconnection: session time: 0:00:00.005 user=avnadmin database=defaultdb host=[local]
finally what i understood that , aiven should provide access of pg_hba.conf to user’s directly, because after adding required ip in IP address allowlist section , still getting below error
!Pg connection failed: FATAL: no pg_hba.conf entry for host “106.219.x.x”, user “avnadmin”, database “defaultdb”, no encryption
“106.219.x.x” is listed in IP address allowlist.
getting error → Connection with Postgres could not be established
even user name is not Postgres.