jerry
I am running Elixir 1.14 on my machine.
I have a config folder with runtime.exs, runtime.prod.exs, and runtime.dev.exs
I reference environment variables inside runtime.prod.exs and runtime.dev.exs.
Things seem to work well in development environment, but things begin to fail when I deploy into production.
The environment variables are not seen, although this is not the case in development environment.
I have tried to revert to config.exs, prod.exs, and dev.exs.
But that is also not working.
Below is a sample error when I attempt to run the application in production:
** (EXIT) an exception was raised:
** (ArgumentError) could not fetch application environment :host_port for application :my_app because configuration at :host_port was not set
Can I get some help on how I should go about the configuration?
Thank you.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Can you post some excerpts from your config?
But I’m thinking it’s likely that some of your config is taken from env vars at compile time.
jerry
I got this, runtime.exs, code from one of the sites:
runtime.dev.exs works fine, but runtime.prod.exs does not.
Inside my application.ex file/module, I have this:
The error I get is:
** (EXIT) an exception was raised:
** (ArgumentError) could not fetch application environment :host_port for application :my_app because configuration at :host_port was not set
dimitarvp
Good, now maybe also try formatting them properly – with triple backticks (```) at the start and end of each block.
jerry
Which block, please?
I seem a little lost…
dimitarvp
The code blocks that you pasted. Surround them with triple backticks – ``` – on the line before and the line after the block. Like so:
This has triple backticks before the first line and after the last line.
derek-zhou
How did you set the environment variables in production? If your runtime.exs does not see them then they were not there. Whatever ways you used to set them must have not worked.
Nicd
In that case it would crash at the System.fetch_env! call.
This syntax doesn’t look correct.
kokolegorille
I made the change for You this time, so You can see your post with format… like in Markdown.
jerry
Thanks to you all for your comments and suggestions.
I have been able to get the configurations to work now.
There was a wrong naming of the environment, prod, and so the environment variables were not being seen.
Does it mean the environment cannot change from dev or prod to any other name or even an additional environment added such as a staging environment, stag?
I am grateful to you all.