Can't connect PostgreSQL to my Django App in Azure VM

Hello,
I am build a django app that I am deploying through a CI/CD pipeline into my Azure VM. I already created a PostgreSQL database. When I deploy my docker container in my VM and try to connect to my database I get the following error :

django.db.utils.OperationalError: connection to server at “127.0.0.1”, port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?

Knowing that the that I get the following when running “netstat -an | grep 5432” :

Can you please help me, I looked for two days in all forums for a solution for this error, but still nothing worked !
Thanks in advance.

Hi! It’s hard to know without knowing the configuration, but it seems like a networking issue. You should check if the database is on the same virtual network as the application or if it is exposed to public networks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.