while accessing postgress flexible server from aks cluster getting error

Kishor 0 Reputation points
2024-07-31T09:57:12.51+00:00

while accessing azure postgress server from my aks cluster i am getting error


error fetching from postgres, err: pq: no pg_hba.conf entry for host \"4.224.139.13\"


this postgress servre is public , while seraching i got a document

Check your SSL settings on the client. Azure database for PostgreSQL Flexible Server has SSL enabled by default. Ensure you enabled the SSL mode from the client , you can refer to our 

this is the way i am connecting to postgress server

```
fmt.Sprintf("host=%s port=%s user=%s "+

"password=%s dbname=%s fmt.Sprintf("host=%s port=%s user=%s "+

"password=%s dbname=%s sslmode=disable TimeZone=Asia/Kolkata",

serverIp, port, user,

password, db) TimeZone=Asia/Kolkata",

serverIp, port, user,

password, db)

```

}

var err error

// Create connection pool

pgObj.conn, err = sql.Open("postgres", dbinfo+" connect_timeout=1")

if err != nil {

// utils.PrintlnLog(constants.ERROR, "Error creating pg connection pool :"+err.Error())

logrus.Error("Error creating pg connection pool :" + err.Error())

return

}

here if i am sslmode=require then which ssl certificate i will provide , can you please help me with this , beacause one certificate i got form azure that i used still getting same issue, please explain me properly.

and also i tried to disable it using this (require _secure_transport" to OFF)

`az resource list -g MC_Pace-NP_Pace-NP_centralindia --resource-type Microsoft.DBforPostgreSQL/flexibleServers

[

{

"changedTime": "2024-07-03T07:26:38.704717+00:00",

"createdTime": "2024-07-03T07:10:30.204319+00:00",

"extendedLocation": null,

"id": "/subscriptions/c79b2c30-a987-4334-b86b-9de5871252a4/resourceGroups/MC_Pace-NP_Pace-NP_centralindia/providers/Microsoft.DBforPostgreSQL/flexibleServers/postgressql-pace",

"identity": null,

"kind": null,

"location": "centralindia",

"managedBy": null,

"name": "postgressql-pace",

"plan": null,

"properties": null,

"provisioningState": "Succeeded",

"resourceGroup": "MC_Pace-NP_Pace-NP_centralindia",

"sku": {

"capacity": null,

"family": null,

"model": null,

"name": "Standard_B1ms",

"size": null,

"tier": "Burstable"

},

"systemData": {

"createdAt": "2024-07-03T07:10:39.2577724Z"

},

"tags": {},

"type": "Microsoft.DBforPostgreSQL/flexibleServers"

},

{

"changedTime": "2024-07-09T10:10:09.760611+00:00",

"createdTime": "2024-07-09T09:53:45.861902+00:00",

"extendedLocation": null,

"id": "/subscriptions/c79b2c30-a987-4334-b86b-9de5871252a4/resourceGroups/MC_Pace-NP_Pace-NP_centralindia/providers/Microsoft.DBforPostgreSQL/flexibleServers/pace-postgress",

"identity": null,

"kind": null,

"location": "centralindia",

"managedBy": null,

"name": "pace-postgress",

"plan": null,

"properties": null,

"provisioningState": "Succeeded",

"resourceGroup": "MC_Pace-NP_Pace-NP_centralindia",

"sku": {

"capacity": null,

"family": null,

"model": null,

"name": "Standard_B1ms",

"size": null,

"tier": "Burstable"

},

"systemData": {

"createdAt": "2024-07-09T09:54:05.5059694Z"

},

"tags": {},

"type": "Microsoft.DBforPostgreSQL/flexibleServers"

}

]

az postgres server show --resource-group MC_Pace-NP_Pace-NP_centralindia --name pace-postgress

(ResourceNotFound) The Resource 'Microsoft.DBforPostgreSQL/servers/pace-postgress' under resource group 'MC_Pace-NP_Pace-NP_centralindia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Code: ResourceNotFound

Message: The Resource 'Microsoft.DBforPostgreSQL/servers/pace-postgress' under resource group 'MC_Pace-NP_Pace-NP_centralindia' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

i don't know why this happening , i can list the postgress sever in the resource group and i can't see the server inside the resource.

my aks cluster version --- 1.28.9
postgress version - 16.3

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,103 questions
Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 24,546 Reputation points
    2024-08-07T19:28:18.02+00:00

    Hi @Kishor

    The error indicates that there is no pg_hba.conf entry for the host IP address that you are using to connect to the Azure PostgreSQL server. This could be due to a misconfiguration of the firewall rules or the SSL settings.

    To troubleshoot this issue, you can try the following steps:

    Check the firewall rules for the Azure PostgreSQL server to ensure that they allow traffic from the IP address that you are using to connect to the server. You can use the Azure portal to manage the firewall rules for the Azure PostgreSQL server.

    Check the SSL settings for the Azure PostgreSQL server to ensure that they are configured correctly. You can refer to the Azure documentation for more information on how to configure SSL for Azure PostgreSQL.

    Try using a different SSL mode, such as "require" or "verify-full", to connect to the Azure PostgreSQL server. You may need to provide a client SSL certificate if you are using the "require" mode.

    Check the logs for the Azure PostgreSQL server to see if there are any error messages or warnings related to the connection issue. This can help you identify the root cause of the issue.

    Consider using a different PostgreSQL client or driver to connect to the Azure PostgreSQL server. Some clients or drivers may have compatibility issues with the Azure PostgreSQL server.

    Regarding the issue with the Azure PostgreSQL server not being found, it seems like there may be an issue with the resource group or the server name.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.