# AWX - psycopg2.OperationalError: server closed the connection unexpectedly

**URL:** <https://forum.ansible.com/t/awx-psycopg2-operationalerror-server-closed-the-connection-unexpectedly/37749>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [March 10, 2023, 2:31am UTC](https://forum.ansible.com/t/awx-psycopg2-operationalerror-server-closed-the-connection-unexpectedly/37749 "2023-03-10T02:31:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jagruti\_Belani](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Jagruti\_Belani](https://forum.ansible.com/u/Jagruti_Belani)\
**Post date:** [March 10, 2023, 2:31am UTC](https://forum.ansible.com/t/awx-psycopg2-operationalerror-server-closed-the-connection-unexpectedly/37749/1 "2023-03-10T02:31:11Z")

</div>

```auto
Hi Team,

```

```auto
Getting this error while running the ansible job on AWX 21.5.0

```

```auto
JOb Errored out during execution.

```

```auto
Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
psycopg2.OperationalError: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 481, in run
    self.pre_run_hook(self.instance, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 1043, in pre_run_hook
    super(RunJob, self).pre_run_hook(job, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 417, in pre_run_hook
    create_partition(instance.event_class._meta.db_table, start=instance.created)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/utils/common.py", line 1163, in create_partition
    cursor.execute(
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
django.db.utils.OperationalError: server closed the connection unexpectedly
	This probably means the server terminated abnormally

```

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [March 10, 2023, 6:43pm UTC](https://forum.ansible.com/t/awx-psycopg2-operationalerror-server-closed-the-connection-unexpectedly/37749/2 "2023-03-10T18:43:15Z")

</div>

what is the status of your database server? does the system ever recover after the failed job?

AWX Team

---

<div class="post-metadata">

**Author:** ![Jagruti\_Belani](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Jagruti\_Belani](https://forum.ansible.com/u/Jagruti_Belani)\
**Post date:** [March 10, 2023, 8:21pm UTC](https://forum.ansible.com/t/awx-psycopg2-operationalerror-server-closed-the-connection-unexpectedly/37749/3 "2023-03-10T20:21:04Z")

</div>

the system automatically recovered on it’s own after 2 hours
