Distillery build not connecting with PostgreSQL

I switched from exrm to distillery in build release for my phoenix project. Everything is working fine. when I do

iex -S mix phx.server

Application runs and everything gets connected with DB. but the build release not connecting with the database. (I think doing above command apart from build its getting dev values for db.)

2018-08-10 08:59:19.160 [error] Postgrex.Protocol (#PID<0.2803.0>) failed to connect: ** (Postgrex.Error) FATAL 53300 (too_many_connections): remaining connection slots are reserved for non-replication superuser connections

when I see /opt/evercam_media/releases/1.0.1/sys.config file it gives me the right values of Database which put there for DB connection

       {mode,prod}]},
  {'Elixir.EvercamMedia.Repo',
      [{adapter,'Elixir.Ecto.Adapters.Postgres'},
       {types,'Elixir.EvercamMedia.PostgresTypes'},
       {url,<<"postgres://localhost/evercam_dev">>},
       {socket_options,[{keepalive,true}]},
       {timeout,60000},
       {pool_timeout,60000},
       {pool_size,80},
       {lazy,false},
       {ssl,true}]},
  {'Elixir.EvercamMedia.SnapshotRepo',
      [{adapter,'Elixir.Ecto.Adapters.Postgres'},
       {url,<<"postgres://localhost/evercam_dev">>},
       {socket_options,[{keepalive,true}]},
       {timeout,60000},
       {pool_timeout,60000},
       {pool_size,100},
       {lazy,false},
       {ssl,true}]}]}].

what is the issue here? It’s not getting connected with the database, what I am doing wrong?

:wave:

The error is “too many connections”. If you have access to the database, try checking if that’s true and maybe tweak its settings.

the database is local. as you can see postgres://localhost/evercam_de

there is no other application getting connected with it.

See sql - psql: FATAL: too many connections for role - Stack Overflow

the database is local. as you can see postgres://localhost/evercam_de

:+1: I’ve just told you what the error said.

Hi @ijunaidfarooq. In your code you have pool_size with 80 and 100 - this is probably too much on local psql settings - you should at first check with pool_size = 10 (like default).
This should fix errors of too_many_connections

4 Likes

Yhea it works fine!

We are using a new DigitalOcean Database, but I was exceeding the pool size that I configure in DO.

Thank you!

1 Like

It solution for me, thanks for help! I was start work with ElephantSQL and on the free plan pool_size=5 (5 concurrent connections). Phoenix don’t start app with ecto until I fixed it.

2 Likes