Failed to connect to database on Minikube

1/28/2022

I am new in Kubernetes and trying to deploy an application that connects to a postgres deployment in Minikube. Before runing the deployments on Minikube, I can run the application outside Minikube on my computer operating system without any problems. But when I run the deployments on Minikube, the application works neither in Minikube nor outside the Minikube. I get these error for each:

error while running application inside Minikube

psycopg2 ERROR: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
        Is the server running on that host and accepting TCP/IP connections?
 on line number: 46
psycopg2 traceback: <traceback object at 0x7f6ce1d3ef40> -- type: <class 'psycopg2.OperationalError'>

extensions.Diagnostics: <psycopg2.extensions.Diagnostics object at 0x7f6ce1d1c5b0>
pgerror: None
pgcode: None

error while running outside Minikube:

connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?

What is here problematic?

-- Bornak
kubernetes
minikube
postgresql

0 Answers