1

Trying to host Django 4 app with PostgreSQL database on Windows Server 2016 with IIS manager 10 and httpPlatformHandler 1.2.

The app and database work without issues when running on a VM server with python manage.py runserver in cmd. The problem comes when trying to access with IIS, the Log file shows:

    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)

and after I changed DB address from localhost ot 127.0.0.1 the error changed to

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) 

and sometimes

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)

I think there is some option in IIS that prevents establishing a connection.

5

1 Answer 1

1

If you haven't done so, you may want to Update your "pg_hba.conf" File, to Allow Connections from Localhost, over IPv4 and 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

You can find additional information here. https://www.postgresql.org/docs/current/auth-pg-hba-conf.html

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .