Connecting local postgresql to kubernetes pods

Hello every body,

i am trying to connect some kubernetes pods (3) to a local postgresql db. For that i have created such a configmap:

apiVersion: v1
kind: ConfigMap
metadata:
name: env
namespace: test
data:
KC_DB: ‘postgres’
KC_DB_URL: ‘jdbc:postgresql://localhost:5432/mydb’
KC_DB_USERNAME: ‘testuser’
KC_DB_PASSWORD: ‘test123’

i deploy it with : kubectl create -f configmap-file -n=test

but in the log of the pods i get this error:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections

locally i can connect to the db with that user name!
my question is, is that possible at all to connect the pods to a local postgresql db?

thanks in advance for yours help and your tipps !

Regards
Maz