Skip to content Skip to sidebar Skip to footer

Can't Run The Server On Django (connection Refused)

I finally (think) installed successfully PostgreSQL and also de psycopg2 (I use Windows). Btw, is some way to check it's working properly? Well, the thing now is that I can't start

Solution 1:

For me it was for postgres not being started and enabled. So I solved the problem by doing so:

sudo systemctl start postgresql
sudo systemctl enable postgresql

Solution 2:

Make port default to 5432

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'database1',                      
    'USER': 'root',
    'PASSWORD': '123456',
    'HOST': 'localhost',
    'PORT': '5432',
    }
}

run the command:

python manage.py runserver 127.0.0.1:8000

Solution 3:

I just had the same problem and I just had forgotten to start my Postgres. Opening it from my Applications and selecting "Open psql" solved the problem.

Solution 4:

If you are using Postgresql and developing on a mac then you can use the below command to start Postgresql and it should fix your problem.

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

and to stop it

pg_ctl -D /usr/local/var/postgres stop -s -m fast

Solution 5:

Try removing host and port:

# settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',
        'USER': 'db_user',
        'PASSWORD': 'db_pass',
    }
}

The problem for me was specifying HOST and/or PORT here.

Post a Comment for "Can't Run The Server On Django (connection Refused)"