# Unable to reach postgres instance

**URL:** <https://community.fly.io/t/unable-to-reach-postgres-instance/22295>\
**Category:** General\
**Tags:** postgres, proxy, login-only\
**Created:** [October 17, 2024, 1:28am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295 "2024-10-17T01:28:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewmcgrath](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@andrewmcgrath](https://community.fly.io/u/andrewmcgrath)\
**Post date:** [October 17, 2024, 1:28am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/1 "2024-10-17T01:28:47Z")

</div>

Anyone else having similar issues? I have made no changes ot my app but suddenly i cant connect to postgres from the app.

PG::ConnectionBad: connection to server at “fdaa:3:711f:0:1::8”, port 5432 failed: server closed the connection unexpectedly (PG::ConnectionBad)  
This probably means the server terminated abnormally  
before or while processing the request.

I’ve never seen this before.

I’ve tried: rebooting instances, destroying machines and re-creating them, deploying the app.

Nothing has changed.

---

<div class="post-metadata">

**Author:** ![Nick416](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Nick416](https://community.fly.io/u/Nick416)\
**Post date:** [October 17, 2024, 1:37am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/2 "2024-10-17T01:37:24Z")

</div>

I am seeing the same thing, both my apps are having issues connecting to the respective Postgres DBs i.e. I am seeing Postgrex.Protocol (#PID\<0.2231.0\>) failed to connect: \*\* (DBConnection.ConnectionError) tcp recv (idle): closed

Seems like one of them will connect off and on. Maybe a fly thing?

---

<div class="post-metadata">

**Author:** ![andrewmcgrath](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@andrewmcgrath](https://community.fly.io/u/andrewmcgrath)\
**Post date:** [October 17, 2024, 1:41am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/3 "2024-10-17T01:41:41Z")

</div>

I’m not sure if i fixed it or if it fixed itself. I did the following:

- updated my postgres to the latest version
- destroyed all the existing machines (app - not postgres)
- scaled the app back up

Then it came online. I did the destroy and and scale up before, but it didnt seem to work…not s sure why it did this time.

---

<div class="post-metadata">

**Author:** ![Nick416](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@Nick416](https://community.fly.io/u/Nick416)\
**Post date:** [October 17, 2024, 1:45am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/4 "2024-10-17T01:45:31Z")

</div>

Thanks, I’ll give that a try, I’m just running some hobby apps at the moment, so at least not a panic haha.

---

<div class="post-metadata">

**Author:** ![andrewmcgrath](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@andrewmcgrath](https://community.fly.io/u/andrewmcgrath)\
**Post date:** [October 17, 2024, 1:46am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/5 "2024-10-17T01:46:33Z")

</div>

Wish i could say the same…ugh nothing worse than customers emailing you about issues you didn’t pickup on.

---

<div class="post-metadata">

**Author:** ![cravingsleep](https://avatars.discourse-cdn.com/v4/letter/c/e47774/32.png) [@cravingsleep](https://community.fly.io/u/cravingsleep)\
**Post date:** [October 17, 2024, 11:50am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/6 "2024-10-17T11:50:31Z")

</div>

Same issue here I think, my app suddenly cannot find my Postgres instance when it was working fine before. I tried destroying my app and scaling back up but it fails to connect everytime.

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [October 17, 2024, 11:54am UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/7 "2024-10-17T11:54:51Z")

</div>

Tags updated on October 17, 2024, 11:54am UTC

Added #postgres

---

<div class="post-metadata">

**Author:** ![andrewmcgrath](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@andrewmcgrath](https://community.fly.io/u/andrewmcgrath)\
**Post date:** [October 17, 2024, 12:06pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/8 "2024-10-17T12:06:55Z")

</div>

Can you reach the db through a wireshark tunnel? I could the entire time which is the only reason i knew the db was fine. I’d check that to rule out any other issues.

---

<div class="post-metadata">

**Author:** ![arguin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/arguin/32/51252_2.png) [@arguin](https://community.fly.io/u/arguin)\
**Post date:** [October 17, 2024, 12:28pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/9 "2024-10-17T12:28:24Z")

</div>

Hi, same here across 4 apps, they all started throwing the same error. It seems it’s only affecting apps in my personal organization, I have two apps in outside organizations and they’re fine.

---

<div class="post-metadata">

**Author:** ![cravingsleep](https://avatars.discourse-cdn.com/v4/letter/c/e47774/32.png) [@cravingsleep](https://community.fly.io/u/cravingsleep)\
**Post date:** [October 17, 2024, 12:31pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/10 "2024-10-17T12:31:53Z")

</div>

Yep db looks fine internally, can reach it through a Fly Proxy and it responds to queries.

---

<div class="post-metadata">

**Author:** ![arguin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/arguin/32/51252_2.png) [@arguin](https://community.fly.io/u/arguin)\
**Post date:** [October 17, 2024, 12:35pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/11 "2024-10-17T12:35:35Z")

</div>

same here!

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [October 17, 2024, 12:52pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/12 "2024-10-17T12:52:28Z")

</div>

Hm… Another thing that could be tried is switching to the `.internal` address instead of the `.flycast` one.

(In your web app’s `DATABASE_URL`—or similar.)

This will no longer auto-start the database or load balance, but it might at least help narrow down the source of the problem…

---

<div class="post-metadata">

**Author:** ![sonalranjit](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/sonalranjit/32/41493_2.png) [@sonalranjit](https://community.fly.io/u/sonalranjit)\
**Post date:** [October 17, 2024, 1:39pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/13 "2024-10-17T13:39:06Z")

</div>

I was suffering from the same issue, the way i resolved it was i rollbacked my postgres instance to a snapshot before the latest snapshot. The new instance from the snapshot didn’t suffer from the same issue. I’m going to assume the daily snapshot was the issue ?

---

<div class="post-metadata">

**Author:** ![arguin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/arguin/32/51252_2.png) [@arguin](https://community.fly.io/u/arguin)\
**Post date:** [October 17, 2024, 1:58pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/14 "2024-10-17T13:58:23Z")

</div>

From my understanding a daily snapshot shouldn’t change anything on the live database.

But it is a probable cause.

Any additional insight here?

---

<div class="post-metadata">

**Author:** ![arguin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/arguin/32/51252_2.png) [@arguin](https://community.fly.io/u/arguin)\
**Post date:** [October 17, 2024, 2:43pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/15 "2024-10-17T14:43:05Z")

</div>

Waiting for a reply from the [Fly.IO](http://Fly.IO) team here.

Should I wait for you guys to actually resolve the issue, or should I try @sonalranjit’s fix?

Seems the issue is on your end.

---

<div class="post-metadata">

**Author:** ![cdoolin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/cdoolin/32/15157_2.png) [@cdoolin](https://community.fly.io/u/cdoolin)\
**Post date:** [October 17, 2024, 3:49pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/16 "2024-10-17T15:49:30Z")

</div>

I can confirm this solution worked - I created a new secret “DATABASE\_URL\_ALT” which replaces “.flycast” with “.internal” and updated my app to use this new var

I am running pretty old versions of flyio/postgres-flex (0.0.39) and haven’t touched the databases forever. Fortunately one instance of my app remained able to connect to the .flycast url, but no other instances or new machines could

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [October 17, 2024, 3:52pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/17 "2024-10-17T15:52:43Z")

</div>

Tags updated on October 17, 2024, 3:52pm UTC

Added #proxy

---

<div class="post-metadata">

**Author:** ![eyouu](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@eyouu](https://community.fly.io/u/eyouu)\
**Post date:** [October 17, 2024, 3:53pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/18 "2024-10-17T15:53:42Z")

</div>

Same for me, all my apps stopped working…

---

<div class="post-metadata">

**Author:** ![Danecki](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/danecki/32/37681_2.png) [@Danecki](https://community.fly.io/u/Danecki)\
**Post date:** [October 17, 2024, 3:57pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/19 "2024-10-17T15:57:19Z")

</div>

My apps conenct to database via ip address and I have similar issue

---

<div class="post-metadata">

**Author:** ![Jay1](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jay1/32/38362_2.png) [@Jay1](https://community.fly.io/u/Jay1)\
**Post date:** [October 17, 2024, 3:58pm UTC](https://community.fly.io/t/unable-to-reach-postgres-instance/22295/20 "2024-10-17T15:58:30Z")

</div>

Yesterday my postgres instance went down the same way, I reprovisioned new with the latest image and did a failover, it seemed to fix the issue.

Now my app can connect to both Redis upstash instances … And as I’m writing this they just added [https://status.flyio.net/incidents/ftd07gnytjl4](https://status.flyio.net/incidents/ftd07gnytjl4) so it may be networking related :-/

[Next page](https://community.fly.io/t/unable-to-reach-postgres-instance/22295.md?page=2)
