Distillery build not connecting with PostgreSQL

phoenix
deployment

#1

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?


#2

: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.


#3

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

there is no other application getting connected with it.


#4

See https://stackoverflow.com/questions/25058649/psql-fatal-too-many-connections-for-role

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

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


#5

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