
Intentando alojar la aplicación Django 4 con la base de datos PostgreSQL en Windows Server 2016 con el administrador IIS 10 y httpPlatformHandler 1.2.
La aplicación y la base de datos funcionan sin problemas cuando se ejecutan en un servidor VM con python manage.py runserver
cmd. El problema surge al intentar acceder con IIS, el archivo de registro muestra:
psycopg.OperationalError: connection failed: :1), port 23825 failed: could not receive data from server: Socket is not connected (0x00002749/10057)
could not send SSL negotiation packet: Socket is not connected (0x00002749/10057)
y después de cambiar la dirección de base de datos de localhost o 127.0.0.1, el error cambió a
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\psycopg\connection.py", line 729, in connect
raise ex.with_traceback(None)
django.db.utils.OperationalError: connection failed: could not receive data from server: Socket is not connected (0x00002749/10057)
could not send SSL negotiation packet: Socket is not connected (0x00002749/10057)
y aveces
psycopg.OperationalError: connection failed: could not receive data from server: Socket is not connected (0x00002749/10057)
could not send SSL negotiation packet: Socket is not connected (0x00002749/10057)
Creo que hay alguna opción en IIS que impide establecer una conexión.
Respuesta1
Si no lo ha hecho, es posible que desee actualizar su archivo "pg_hba.conf" para permitir conexiones desde Localhost a través de IPv4 e IPv6.
#TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 trust
host all all localhost trust
host all all ::1/128 trust
Puede encontrar información adicional aquí. https://www.postgresql.org/docs/current/auth-pg-hba-conf.html