sushant12

sushant12

Issue deploying to gigalixir - (RuntimeError) connect raised KeyError exception: key :database not found

I am having an issue deploying my phoenix app to gigalixir.

2019-09-24T01:05:40.350124+00:00 stipe[stipe-767f97457f-657ng]: web.1  | ** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
2019-09-24T01:05:40.350152+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (elixir) lib/keyword.ex:393: Keyword.fetch!/2
2019-09-24T01:05:40.350182+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (postgrex) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
2019-09-24T01:05:40.350260+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
2019-09-24T01:05:40.350286+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (connection) lib/connection.ex:622: Connection.enter_connect/5
2019-09-24T01:05:40.350315+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
2019-09-24T01:05:40.350334+00:00 stipe[stipe-767f97457f-657ng]: web.1  | Last message: nil
2019-09-24T01:05:40.350452+00:00 stipe[stipe-767f97457f-657ng]: web.1  | 01:05:40.270 [error] GenServer #PID<0.1683.0> terminating
2019-09-24T01:05:40.350459+00:00 stipe[stipe-767f97457f-657ng]: web.1  | ** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
2019-09-24T01:05:40.350460+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (elixir) lib/keyword.ex:393: Keyword.fetch!/2
2019-09-24T01:05:40.350463+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (postgrex) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
2019-09-24T01:05:40.350504+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
2019-09-24T01:05:40.350585+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (connection) lib/connection.ex:622: Connection.enter_connect/5
2019-09-24T01:05:40.350620+00:00 stipe[stipe-767f97457f-657ng]: web.1  |     (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
2019-09-24T01:05:40.350645+00:00 stipe[stipe-767f97457f-657ng]: web.1  | Last message: nil
2019-09-24T01:05:40.350692+00:00 stipe[stipe-767f97457f-657ng]: web.1  | 01:05:40.271 [info] Application stipe exited: shutdown
2019-09-24T01:05:40+00:00 stipe[gigalixir]: Readiness probe failed: dial tcp 10.56.12.134:4000: connect: connection refused
2019-09-24T01:05:41.359831+00:00 stipe[stipe-5c6c65949d-84thz]: web.1  | {"Kernel pid terminated",application_controller,"{application_terminated,stipe,shutdown}"}
2019-09-24T01:05:41.359881+00:00 stipe[stipe-5c6c65949d-84thz]: web.1  | Kernel pid terminated (application_controller) ({application_terminated,stipe,shutdown})
2019-09-24T01:05:41.362196+00:00 stipe[stipe-5c6c65949d-84thz]: web.1  | 
2019-09-24T01:05:41.782657+00:00 stipe[stipe-767f97457f-657ng]: web.1  | {"Kernel pid terminated",application_controller,"{application_terminated,stipe,shutdown}"}
2019-09-24T01:05:41.782745+00:00 stipe[stipe-767f97457f-657ng]: web.1  | Kernel pid terminated (application_controller) ({application_terminated,stipe,shutdown})
2019-09-24T01:05:41.786425+00:00 stipe[stipe-767f97457f-657ng]: web.1  | 
2019-09-24T01:05:43+00:00 stipe[gigalixir]: Readiness probe failed: dial tcp 10.56.12.134:4000: connect: connection refused

And this is my prod.exs file

config :stipe, StipeWeb.Endpoint,
  load_from_system_env: true,
  # Needed for Phoenix 1.2 and 1.4. Doesn't hurt for 1.3.
  http: [port: {:system, "PORT"}],
  # Without this line, your app will not start the web server!
  server: true,
  secret_key_base: "${SECRET_KEY_BASE}",
  url: [host: "${APP_NAME}.gigalixirapp.com", port: 443],
  cache_static_manifest: "priv/static/cache_manifest.json"

config :stipe, StipeWeb.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: "${DATABASE_URL}",
  database: "",
  ssl: true,
  show_sensitive_data_on_connection_error: true,
  # Free tier db only allows 4 connections. Rolling deploys need pool_size*(n+1) connections where n is the number of app replicas.
  pool_size: 2

I wonder why it cant connect to db as mentioned in the logs. And even with the show_sensitive_data_on_connection_error: true, enabled I still see the enable it to show sensitive info message in the log

Also I am using distillery.

Marked As Solved

jesse

jesse

Just a guess, but try replacing StipeWeb.Repo with Stipe.Repo

Also Liked

jesse

jesse

No worries! It’s actually a very common error. I see it almost everyday.

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Other popular topics Top

rms.mrcs
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
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement