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 the server, while I type 'python manage.py runserver' it shows this (at the end of the command):
conn = _connect(dsn, connection_factory=connection_factory, async=async) django.db.utils.OperationalError: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 8000? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 8000?
I've searched a lot of documentation about it, for example in this topic, but I can't find the way to make it work properly. I've tried several changes in the pg_hba and postgresql files, but with no exit. In this moment, pg_hba looks like:
# TYPE DATABASE USER ADDRESS METHOD # IPv4 local connections: host all all 127.0.0.1 md5 # IPv6 local connections: host all all 127.0.0.1 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #host replication postgres 127.0.0.1/32 md5 #host replication postgres ::1/128 md5
And postgresql conf looks like:
# - Connection Settings - listen_addresses = 'localhost' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) port = 8000 # (change requires restart) max_connections = 100 # (change requires restart) # Note: Increasing max_connections costs ~400 bytes of shared memory per # connection slot, plus lock space (see max_locks_per_transaction). #superuser_reserved_connections = 3 # (change requires restart) #unix_socket_directories = '' # comma-separated list of directories # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation # (change requires restart) #bonjour = off # advertise server via Bonjour # (change requires restart) #bonjour_name = '' # defaults to the computer name
Btw, my settings.py of the database look like this:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'database1', 'USER': 'root', 'PASSWORD': '123456', 'HOST': 'localhost', 'PORT': '8000', } }
I haven't created a database BTW, how should I do it? What are the applications of the PostgreSQL prompt?
I would highly appreciate help with this issue I've been days searching and trying but with no exit. Thank you very much.
EDIT 1: I tried changing the settings.py port to 5432, but now the error message is the same, just changing the port:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
The config files are right this way? Should I change something? I can't find an answer. I tried with python manage.py runserver
and both indicating the 127.0.0.1:8000
and 8001, but no changes in the error message. What's going wrong? Thank you very much.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With