Error deploying to VPS: (RuntimeError) environment variable DATABASE_URL is missing

Dear All,
I was try deploy into my vps with this step :

  • MIX_ENV=prod mix release (success)
  • _build/prod/rel/myweb/bin/myweb start (failed)

but it’s showed error like below :

_build/prod/rel/myweb/bin/myweb start
ERROR! Config provider Config.Reader failed with:
** (RuntimeError) environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE

    /var/www/myweb.com/myweb/_build/prod/rel/myweb/releases/0.1.0/runtime.exs:26: (file)
    (elixir 1.17.3) src/elixir.erl:386: :elixir.eval_external_handler/3
    (stdlib 6.1.2) erl_eval.erl:904: :erl_eval.do_apply/7
    (stdlib 6.1.2) erl_eval.erl:648: :erl_eval.expr/6
    (stdlib 6.1.2) erl_eval.erl:271: :erl_eval.exprs/6
    (elixir 1.17.3) src/elixir.erl:364: :elixir.eval_forms/4
    (elixir 1.17.3) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
    (elixir 1.17.3) lib/code.ex:572: Code.validated_eval_string/3

Runtime terminating during boot ({#{message=><<101,110,118,105,114,111,110,109,101,110,116,32,118,97,114,105,97,98,108,101,32,68,65,84,65,66,65,83,69,95,85,82,76,32,105,115,32,109,105,115,115,105,110,103,46,10,70,111,114,32,101,120,97,109,112,108,101,58,32,101,99,116,111,58,47,47,85,83,69,82,58,80,65,83,83,64,72,79,83,84,47,68,65,84,65,66,65,83,69,10>>,'__struct__'=>'Elixir.RuntimeError','__exception__'=>true},[{elixir_eval,'__FILE__',1,[{file,"/var/www/myweb.com/myweb/_build/prod/rel/myweb/releases/0.1.0/runtime.exs"},{line,26}]},{elixir,eval_external_handler,3,[{file,"src/elixir.erl"},{line,386},{error_info,#{module=>'Elixir.Exception'}}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,904}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,648}]},{erl_eval,exprs,6,[{file,"erl_eval.erl"},{line,271}]},{elixir,eval_forms,4,[{file,"src/elixir.erl"},{line,364}]},{'Elixir.Module.ParallelChecker',verify,1,[{file,"lib/module/parallel_checker.ex"},{line,112}]},{'Elixir.Code',validated_eval_string,3,[{file,"lib/c

Crash dump is being written to: erl_crash.dump...done

I try to follow type this into command prompt

  • mix phx.gen.secret REALLY_LONG_SECRET ( have created and get the secret code)
  • export SECRET_KEY_BASE=REALLY_LONG_SECRET ( i copied here then enter) next below i don’t know the parameter that should i fill it to change
  • export DATABASE_URL=ecto://USER:PASS@HOST/database

does in USER it’s mean my username in server ?
does it PASS it’s mean my database password ?
does it database it’s mean my database name in server ?

Looks like you’re missing the environment variable for the database url. Try setting that and trying again.

2 Likes

I try to follow type this into command prompt

  • mix phx.gen.secret REALLY_LONG_SECRET ( have created and get the secret code)

  • export SECRET_KEY_BASE=REALLY_LONG_SECRET ( i copied here then enter) next below i don’t know the parameter that should i fill it to change

  • export DATABASE_URL=ecto://USER:PASS@HOST/database

does in USER it’s mean my username in server ?
does it PASS it’s mean my database password ?
does it database it’s mean my database name in server ?

Yes to all three questions.

1 Like

It’s solved now,
the guidelines make confuse in this setting
image

That’s should type like this
export DATABASE_URL=ecto://USERNAMEDATABASE:PASS@localhost:5432/databasename

but i facing the next error like this :

i have make chown -R for the folder also
i have make chmod -R 755 for the folder

Does my Nginx setting is incorret, please give me insight

It’s Solved Now, i just follow the instruction here
https://damonvjanis.medium.com/archive-phoenix-deployments-on-gcp-with-nginx-911730f84d3b

Just the point here :

1 Like