django.db.utils.OperationalError: SSL SYSCALL error: Success when connecting to Postgres DB on new account

Using psycopg2, when I am connecting to a new DB on a new app, I am getting this error:

  File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/", line 275, in get_new_connection
    connection = self.Database.connect(**conn_params)
  File "/usr/local/lib/python3.11/site-packages/psycopg2/", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: SSL SYSCALL error: Success

What can I do to fix this?

Hi… The Success in this case may really be a misreported premature EOF:

The best place to start looking is probably within your Django connection settings…

In particular, if access is via your own private Flycast network, then you typically can’t require SSL on the client side. E.g.,

# psql 'postgres://user_name:password@my-db-app-name.flycast:5432/database_name?sslmode=require'
psql: error: SSL SYSCALL error: Success

(Note the sslmode=require way over at the end of the first line.)

YES! Thank you. I removed ssl_require from the dj_database_url connection code:

DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.