# AWX postgres container stuck in Restarting status

**URL:** <https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [October 4, 2017, 8:59am UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678 "2017-10-04T08:59:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![senilio](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@senilio](https://forum.ansible.com/u/senilio)\
**Post date:** [October 4, 2017, 8:59am UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/1 "2017-10-04T08:59:02Z")

</div>

Hi!

I installed AWX a couple of weeks back, and have been using it without issues since then. Yesterday I got an “Internal Server Error” from the GUI, and then I noticed that the postgres container had crashed, and is stuck in “Restarting” status.

The only output from “docker logs postgres” is a repeating:

initdb: directory “/var/lib/postgresql/data” exists but is not empty  
If you want to create a new database system, either remove or empty  
the directory “/var/lib/postgresql/data” or run initdb  
with an argument other than “/var/lib/postgresql/data”.  
initdb: directory “/var/lib/postgresql/data” exists but is not empty  
If you want to create a new database system, either remove or empty  
the directory “/var/lib/postgresql/data” or run initdb  
with an argument other than “/var/lib/postgresql/data”.  
The files belonging to this database system will be owned by user “postgres”.  
This user must also own the server process.  
The database cluster will be initialized with locale “en\_US.utf8”.  
The default database encoding has accordingly been set to “UTF8”.  
The default text search configuration will be set to “english”.  
Data page checksums are disabled.

In troubleshooting, I upgraded the awx from github and re-ran the installer, but the issue persists.

I also tried moving /tmp/pgdocker out of the way, and then rerunning the installer to see if it would properly generate an emtpy DB and run from that. That works, but this means I’m starting from scratch. And there’s nothing saying this won’t happen again, so I’d rather not start over before pin pointing the issue.

Any ideas on how I could troubleshoot this further?

Thanks!

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 4, 2017, 12:10pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/2 "2017-10-04T12:10:06Z")

</div>

We’ve had this reported a couple of times and I have yet to reproduce it locally (though I have no doubt of its severity). I need to figure out why the postgres container is insisting on re-running its init utility and then failing to start up when data already exists there.

---

<div class="post-metadata">

**Author:** ![Giordano\_Bianchi](https://avatars.discourse-cdn.com/v4/letter/g/45deac/32.png) [@Giordano\_Bianchi](https://forum.ansible.com/u/Giordano_Bianchi)\
**Post date:** [October 5, 2017, 7:14am UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/3 "2017-10-05T07:14:42Z")

</div>

Hi,

FYI I had the same issue when I updated my environemt and I had to delete the /tmp/pgdocker folder to get it to work.  
Since it was a lab environment I didn’t look into the issue further…

---

<div class="post-metadata">

**Author:** ![Stephen\_Dorman](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Stephen\_Dorman](https://forum.ansible.com/u/Stephen_Dorman)\
**Post date:** [October 30, 2017, 8:22pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/4 "2017-10-30T20:22:28Z")

</div>

This is repeatedly happening to our dev instances. They will be working fine, and then all of sudden you will see “A server error has occurred” when trying to access the UI. Every time it has been that the postgres container is stuck in “restarting” status.

Any troubleshooting advice? I have been unsuccessful in recovering the container once it gets in this state. As mentioned above, deleting /tmp/pgdocker means AWX re-initializes and you start from scratch. We’ve been having to roll back to stable snapshots each time this happens.

Thanks,  
Stephen

---

<div class="post-metadata">

**Author:** ![Tony\_Coffman](https://avatars.discourse-cdn.com/v4/letter/t/65b543/32.png) [@Tony\_Coffman](https://forum.ansible.com/u/Tony_Coffman)\
**Post date:** [October 30, 2017, 8:27pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/5 "2017-10-30T20:27:17Z")

</div>

+1

I ended up rebuilding my DEV on OpenShift rather than docker to resolve this because I couldn’t figure out the issue on docker.

–Tony

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 31, 2017, 1:46pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/6 "2017-10-31T13:46:32Z")

</div>

I’m going to see about wrapping this up today, here’s the issue: [https://github.com/ansible/awx/issues/438](https://github.com/ansible/awx/issues/438)

---

<div class="post-metadata">

**Author:** ![Stephen\_Dorman](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Stephen\_Dorman](https://forum.ansible.com/u/Stephen_Dorman)\
**Post date:** [November 20, 2017, 8:59pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/7 "2017-11-20T20:59:30Z")

</div>

I did a full install after issue 438 was closed and merged, but I am still seeing this issue.

`

[root@awx-staging /]# docker ps |grep postgres

eadae4f62e7a postgres:9.6 “docker-entrypoint.sh” 2 weeksnago Restarting (1) 4 minutes ago 5432/tcp postgres

`

`

[root@awx-staging /]# docker logs postgres

initdb: directory “/var/lib/postgresql/data/pgdata” exists but is not empty

If you want to create a new database system, either remove or empty

the directory “/var/lib/postgresql/data/pgdata” or run initdb

with an argument other than “/var/lib/postgresql/data/pgdata”.

The files belonging to this database system will be owned by user “postgres”.

This user must also own the server process.

The database cluster will be initialized with locale “en\_US.utf8”.

The default database encoding has accordingly been set to “UTF8”.

The default text search configuration will be set to “english”.

Data page checksums are disabled.

`

Any suggestions? Thanks!  
-Stephen

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [November 21, 2017, 11:48am UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/8 "2017-11-21T11:48:06Z")

</div>

You’ll want to make sure you clear the pg container, the images, and probably clear the postgres data directory.

---

<div class="post-metadata">

**Author:** ![Stephen\_Dorman](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Stephen\_Dorman](https://forum.ansible.com/u/Stephen_Dorman)\
**Post date:** [November 21, 2017, 6:15pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/9 "2017-11-21T18:15:37Z")

</div>

Sorry, my last message probably wasn’t very clear.

I started with a clean Centos7 install and deployed AWX after the 438 issue was closed. Previously, this issue would surface within a week - the UI would show “A server error has occurred” and upon investigation the postgres container would be stuck restarting. This most recent install lasted over 2 weeks, but the same issue is back. Clearing the pg container, data, etc obviously clears all data and settings which is quite obnoxious.

Anyone else having this issue still?

Thanks,  
Stephen

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [November 21, 2017, 6:45pm UTC](https://forum.ansible.com/t/awx-postgres-container-stuck-in-restarting-status/25678/10 "2017-11-21T18:45:06Z")

</div>

You’ll continue to have the problem if you are using your existing pg container and data. I left the outline for a migration path in the PR linked for that issue closure.
