[Python] How to properly connect PostgreSQL with Django?

Discussão em 'Python' iniciado por Stack, Março 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a Django project and using PostgreSQL as my database. I updated my settings.py as follows:

    **

    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'mydatabase',
    'USER': 'myuser',
    'PASSWORD': 'mypassword',
    'HOST': 'localhost',
    'PORT': '5432',
    }
    }


    **

    However, when I run python manage.py migrate, I get the following error:

    django.db.utils.OperationalError: could not connect to server: Connection refused

    I have PostgreSQL installed and running. I also verified that my credentials are correct. What could be the issue?

    Continue reading...

Compartilhe esta Página