I'm having an issue with a Django site that cannot create a superuser with a PostgreSQL database.
From the development machine
python manage.py createsuperuser --username user1 --email [email protected]
returns:
django.db.utils.OperationalError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
Now, the PostgreSQL server is up. I can run python manage.py migrate
and create tables over there. I can also tell the server is up by putting in incorrect credentials, and receiving an error for having bad creds. I've got Dbeaver up and running on the same machine the Django site is being developed on, and it can connect and see the database as the user the Django site's settings.py
is using.
From the PostgreSQL Server machine
Running cat /var/lib/pgsql/data/pg_log/postgresql-Mon.log
yields the following after an attempted superuser creation:
LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection with an open transaction
Because I can connect to the server and have success with other queries, I'm not sure where this issue lies.
Where should I look next to troubleshoot this issue?
EDIT: UPDATE
I changed postgresql.conf
to reflect log_statement = 'all'
. Now, upon running the createsuperuser command, I see the following in the PostgreSQL log:
LOG: statement:
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)
LOG: statement: SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"
LOG: statement: SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" = 'user1'
LOG: statement: BEGIN
LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection with an open transaction
log_statement = 'all'
inpostgresql.conf
. Now I see a couple SELECT's come through from Django, and then I get this one,statement: BEGIN
*next 2 lines are the LOG: error's from above. Connection reset by peer unexpected EOF on client connection with open transaction – Joshua Schlichting