
IIS 관리자 10 및 httpPlatformHandler 1.2를 사용하여 Windows Server 2016에서 PostgreSQL 데이터베이스로 Django 4 앱을 호스팅하려고 합니다.
cmd를 사용하여 VM 서버에서 실행할 때 앱과 데이터베이스가 문제 없이 작동합니다 python manage.py runserver
. IIS로 액세스하려고 할 때 문제가 발생하며 로그 파일에 다음이 표시됩니다.
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)
localhost 또는 127.0.0.1에서 DB 주소를 변경한 후 오류가 다음으로 변경되었습니다.
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)
그리고 때때로
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)
IIS에는 연결 설정을 방지하는 몇 가지 옵션이 있다고 생각합니다.
답변1
아직 수행하지 않은 경우 "pg_hba.conf" 파일을 업데이트하여 IPv4 및 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
여기에서 추가 정보를 확인할 수 있습니다. https://www.postgresql.org/docs/current/auth-pg-hba-conf.html