# "502 Bad Gateway" when using Postgres database on external server

**URL:** https://help.galaxyproject.org/t/502-bad-gateway-when-using-postgres-database-on-external-server/6664
**Category:** Uncategorized
**Tags:** devops-administration, devops-ansible, devops
**Created:** [September 10, 2021, 8:38pm UTC](https://help.galaxyproject.org/t/502-bad-gateway-when-using-postgres-database-on-external-server/6664 "2021-09-10T20:38:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Devin\_Bougie](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/devin_bougie/32/2741_2.png) [@Devin\_Bougie](https://help.galaxyproject.org/u/Devin_Bougie)
#### Post date: [September 10, 2021, 8:38pm UTC](https://help.galaxyproject.org/t/502-bad-gateway-when-using-postgres-database-on-external-server/6664/1 "2021-09-10T20:38:19Z")

</div>

Hello. We have galaxy installed following the “Galaxy Installation with Ansible” tutorial ([Galaxy Installation with Ansible](https://training.galaxyproject.org/training-material/topics/admin/tutorials/ansible-galaxy/tutorial.html)). Everything is working fine until we try to change the database\_connection string to use our central Postgres server instead of localhost.

When we change this to:  
database \_connection: “postgresql://galaxy:password@pg1/galaxy”

The page fails to load with a “502 Bad Gateway.” If we revert it to the original, everything works.

We have tested the database\_connection string from the command line using “psql -Atx postgresql://galaxy:password@pg1/galaxy”

Any help or suggestions would be greatly appreciated.

Many thanks,  
Devin

---

<div class="post-metadata">

### Author: ![Devin\_Bougie](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/devin_bougie/32/2741_2.png) [@Devin\_Bougie](https://help.galaxyproject.org/u/Devin_Bougie)
#### Post date: [September 11, 2021, 8:53pm UTC](https://help.galaxyproject.org/t/502-bad-gateway-when-using-postgres-database-on-external-server/6664/2 "2021-09-11T20:53:58Z")

</div>

I finally fixed this by updating pg\_hba.conf on the remote server to give the galaxy user access to the postgres database in addition to the galaxy database.

Is it sufficient for galaxy to have read-only access to this database as long as it has full privs over the galaxy database? If not, any details on exactly what it needs to access and do from the postgres database would be greatly appreciated.

Many thanks,  
Devin

---

<div class="post-metadata">

### Author: ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)
#### Post date: [March 17, 2026, 5:50am UTC](https://help.galaxyproject.org/t/502-bad-gateway-when-using-postgres-database-on-external-server/6664/3 "2026-03-17T05:50:41Z")

</div>


