# Error with fly postgres attach command

**URL:** <https://community.fly.io/t/error-with-fly-postgres-attach-command/3706>\
**Category:** Questions / Help\
**Tags:** elixir, postgres\
**Created:** [January 19, 2022, 9:40am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706 "2022-01-19T09:40:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SukinoVerse](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/sukinoverse/32/2564_2.png) [@SukinoVerse](https://community.fly.io/u/SukinoVerse)\
**Post date:** [January 19, 2022, 9:40am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/1 "2022-01-19T09:40:39Z")

</div>

I have an issue while using `fly postgres attach`.

My steps are

- created a new elixir app
- created a new postgres app
- attach postgres app to my elixir app.
- got some errors

my solution is to repeat the command until it is successful. 😂

 ![Screen Shot 2022-01-19 at 16.26.20](https://global.discourse-cdn.com/fly1/original/3X/7/9/79bfbdd9639a62e97cc592b4de62d62b112ddde3.jpeg)

I’m not sure it related with [Unable to attach database to app w/ "Unknown Error" - #22 by shaun](https://community.fly.io/t/unable-to-attach-database-to-app-w-unknown-error/3249/22)

---

<div class="post-metadata">

**Author:** ![shaun](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@shaun](https://community.fly.io/u/shaun)\
**Post date:** [January 19, 2022, 10:18am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/2 "2022-01-19T10:18:24Z")

</div>

That’s strange, are there any notable errors within your Postgres logs?

UPDATE:

Just saw the error at the very top of the screenshot regarding the tunnel issue. What region are you deploying in?

---

<div class="post-metadata">

**Author:** ![SukinoVerse](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/sukinoverse/32/2564_2.png) [@SukinoVerse](https://community.fly.io/u/SukinoVerse)\
**Post date:** [January 19, 2022, 10:45am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/3 "2022-01-19T10:45:08Z")

</div>

Oh, sorry that I didn’t check for a Postgres log at the time I’m using `fly postgres attach` command.

I deployed to the Singapore region for both elixir and Postgres apps.

my colleague also experienced this issue a few days ago when they attach new Postgres to the new elixir app also.

May be it related to Singapore region? 🤔

---

<div class="post-metadata">

**Author:** ![Hannes\_Nevalainen](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/hannes_nevalainen/32/44831_2.png) [@Hannes\_Nevalainen](https://community.fly.io/u/Hannes_Nevalainen)\
**Post date:** [January 23, 2022, 3:46pm UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/4 "2022-01-23T15:46:18Z")

</div>

I’m seeing the same thing for my test-app in Frankfurt 😕

```auto
fly postgres attach --postgres-app pg-dev-test
Running flyadmin user-list
Running flyadmin user-create
Running flyadmin grant-access
Error unexpected end of JSON 

```

---

<div class="post-metadata">

**Author:** ![shaun](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@shaun](https://community.fly.io/u/shaun)\
**Post date:** [January 23, 2022, 3:57pm UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/5 "2022-01-23T15:57:01Z")

</div>

@Hannes_Nevalainen Are you finding that this is an intermittent issue? Or is it happening consistently?

---

<div class="post-metadata">

**Author:** ![Hannes\_Nevalainen](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/hannes_nevalainen/32/44831_2.png) [@Hannes\_Nevalainen](https://community.fly.io/u/Hannes_Nevalainen)\
**Post date:** [January 23, 2022, 4:00pm UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/6 "2022-01-23T16:00:03Z")

</div>

I retried it a few times, then I found this thread which suggested I should try some more… and now it worked. So yes, I would call it intermittent 🙂

---

<div class="post-metadata">

**Author:** ![blanst](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@blanst](https://community.fly.io/u/blanst)\
**Post date:** [February 6, 2022, 9:21am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/7 "2022-02-06T09:21:03Z")

</div>

I also ran into this issue a couple of times deploying to the Chennai region. Succeeded on the third try.

---

<div class="post-metadata">

**Author:** ![Rotwang](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rotwang/32/4326_2.png) [@Rotwang](https://community.fly.io/u/Rotwang)\
**Post date:** [March 13, 2022, 2:51pm UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/8 "2022-03-13T14:51:36Z")

</div>

I want to use [fly.io](http://fly.io) very much indeed. However it keeps making my life miserable, right now I hit this very issue in Frankfurt and London. Should I keep on trying in all the regions?

PS  
it worked in Madrid

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [March 13, 2022, 3:58pm UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/9 "2022-03-13T15:58:44Z")

</div>

You’re running `fly pg attach` and it’s failing? Can you paste the output you’re seeing when you run it?

---

<div class="post-metadata">

**Author:** ![blasrodri](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/blasrodri/32/2840_2.png) [@blasrodri](https://community.fly.io/u/blasrodri)\
**Post date:** [March 19, 2022, 11:44am UTC](https://community.fly.io/t/error-with-fly-postgres-attach-command/3706/10 "2022-03-19T11:44:50Z")

</div>

```auto
$ flyctl pg attach --postgres-app <APP NAME>
Running flyadmin database-list
Running flyadmin user-list
Error unexpected end of JSON input

```
