lamporchestra
Cannot connect ecto to pgbouncer deployed in fly io
Hi everyone.
We are trying to use pgbouncer in front of a postgres. The pgbouncer is deployed as a flyio app,
and our elixir service is also deployed in fly io too.
We have also verified we can connect to the pgbouncer using psql and with running Postgrex.start_link/1 directly.
However, when using ecto, we are still receiving errors.
Example with Postgrex
iex(1)> Mix.install([:postgrex])
:ok
iex(2)> {:ok, pid} = Postgrex.start_link(hostname: "some-pg-bouncer-stg.fly.dev", port: 6432, username: "usernamehere", password: "passwordhere", database: "dbhere", socket_options: [:inet6])
{:ok, #PID<0.244.0>}
iex(3)> Postgrex.query!(pid, "SELECT id from tickets limit 1", [])
%Postgrex.Result{
command: :select,
columns: ["id"],
rows: [
[84058]
],
num_rows: 1,
connection_id: 1803789234,
messages: []
}
However, setting the same options in our config files
config :db, DB.Repo,
username: "usernamehere",
password: "passwordhere",
hostname: "some-pg-bouncer-stg.fly.dev",
database: "dbhere",
port: 6432,
socket_options: [:inet6],
causes our application to keep failing to connect with logs like
[error] Postgrex.Protocol (#PID<0.522.0>) failed to connect: ** (DBConnection.ConnectionError) tcp recv (idle): closed
Any ideas on what options to pass to the Ecto.Repo config or what other changes are needed to make this work?
Marked As Solved
josevalim
Creator of Elixir
I am on my phone but there is a prepare: :unnamed option you can pass. I believe it is documented in Postgrex docs/README. Search for pgbouncer. ![]()
1
Popular in Questions
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<%= ...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Other popular topics
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
Got a question about when to concat vs. prepending items to list then reversing to achieve appending.
So i know lists boil down to [1 | ...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








