biske

biske

Error with DATABASE_URL when deploying Phoenix application to Heroku

Hi, I’m following phoenix/guides/deployment/heroku.md at main · phoenixframework/phoenix · GitHub to deploy using Heroku containers.

Here’s the example repo: GitHub - biske/hello: Basic Phoenix application to test deployment to Heroku · GitHub

When I push to heroku I get following error:

Apples-MacBook-Pro:hello ivanbisevac$ git push heroku master
Enumerating objects: 83, done.
Counting objects: 100% (83/83), done.
Delta compression using up to 8 threads
Compressing objects: 100% (75/75), done.
Writing objects: 100% (83/83), 97.06 KiB | 6.93 MiB/s, done.
Total 83 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: === Fetching app code
remote: 
remote: === Building web (Dockerfile)
remote: Sending build context to Docker daemon  368.6kB
remote: Step 1/25 : FROM elixir:1.9.0-alpine AS build
remote: 1.9.0-alpine: Pulling from library/elixir
remote: e7c96db7181b: Pulling fs layer
remote: c306444e2774: Pulling fs layer
remote: 4b80324f258b: Pulling fs layer
remote: e7c96db7181b: Verifying Checksum
remote: e7c96db7181b: Download complete
remote: 4b80324f258b: Verifying Checksum
remote: 4b80324f258b: Download complete
remote: e7c96db7181b: Pull complete
remote: c306444e2774: Verifying Checksum
remote: c306444e2774: Download complete
remote: c306444e2774: Pull complete
remote: 4b80324f258b: Pull complete
remote: Digest: sha256:bd6e03f00f57a121f6f31374d693e9027ce6053e25700be4d7c64f83dd249a56
remote: Status: Downloaded newer image for elixir:1.9.0-alpine
remote:  ---> 7a6d28e4b511
remote: Step 2/25 : RUN apk add --update build-base npm git
remote:  ---> Running in 244929b60841
remote: fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
remote: fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
remote: (1/31) Upgrading musl (1.1.20-r4 -> 1.1.20-r5)
remote: (2/31) Installing binutils (2.31.1-r2)
remote: (3/31) Installing libmagic (5.36-r1)
remote: (4/31) Installing file (5.36-r1)
remote: (5/31) Installing gmp (6.1.2-r1)
remote: (6/31) Installing isl (0.18-r0)
remote: (7/31) Installing libgomp (8.3.0-r0)
remote: (8/31) Installing libatomic (8.3.0-r0)
remote: (9/31) Installing libgcc (8.3.0-r0)
remote: (10/31) Installing mpfr3 (3.1.5-r1)
remote: (11/31) Installing mpc1 (1.0.3-r1)
remote: (12/31) Installing libstdc++ (8.3.0-r0)
remote: (13/31) Installing gcc (8.3.0-r0)
remote: (14/31) Installing musl-dev (1.1.20-r5)
remote: (15/31) Installing libc-dev (0.7.1-r0)
remote: (16/31) Installing g++ (8.3.0-r0)
remote: (17/31) Installing make (4.2.1-r2)
remote: (18/31) Installing fortify-headers (1.0-r0)
remote: (19/31) Installing build-base (0.5-r1)
remote: (20/31) Installing nghttp2-libs (1.35.1-r1)
remote: (21/31) Installing libssh2 (1.9.0-r1)
remote: (22/31) Installing libcurl (7.64.0-r3)
remote: (23/31) Installing expat (2.2.8-r0)
remote: (24/31) Installing pcre2 (10.32-r1)
remote: (25/31) Installing git (2.20.1-r0)
remote: (26/31) Upgrading musl-utils (1.1.20-r4 -> 1.1.20-r5)
remote: (27/31) Installing c-ares (1.15.0-r0)
remote: (28/31) Installing http-parser (2.8.1-r0)
remote: (29/31) Installing libuv (1.23.2-r0)
remote: (30/31) Installing nodejs (10.14.2-r0)
remote: (31/31) Installing npm (10.14.2-r0)
remote: Executing busybox-1.29.3-r10.trigger
remote: OK: 235 MiB in 51 packages
remote: Removing intermediate container 244929b60841
remote:  ---> c32d9dd1e1ab
remote: Step 3/25 : RUN mkdir /app
remote:  ---> Running in 1421ee00b856
remote: Removing intermediate container 1421ee00b856
remote:  ---> 99aace19d0bf
remote: Step 4/25 : WORKDIR /app
remote:  ---> Running in e1cb3f87b4d0
remote: Removing intermediate container e1cb3f87b4d0
remote:  ---> c37e5c3877f2
remote: Step 5/25 : RUN mix local.hex --force &&     mix local.rebar --force
remote:  ---> Running in 35ced8130ede
remote: * creating /root/.mix/archives/hex-0.20.1
remote: * creating /root/.mix/rebar
remote: * creating /root/.mix/rebar3
remote: Removing intermediate container 35ced8130ede
remote:  ---> afa2e665d580
remote: Step 6/25 : ENV MIX_ENV=prod
remote:  ---> Running in f5b1950ab144
remote: Removing intermediate container f5b1950ab144
remote:  ---> 8e416fc55c15
remote: Step 7/25 : COPY mix.exs mix.lock ./
remote:  ---> 2c89dc19046c
remote: Step 8/25 : COPY config config
remote:  ---> 5ac08e894b10
remote: Step 9/25 : RUN mix deps.get
remote:  ---> Running in 161800382fd6
remote: ** (RuntimeError) environment variable DATABASE_URL is missing.
remote: For example: ecto://USER:PASS@HOST/DATABASE
remote: 
remote:     (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
remote:     (stdlib) erl_eval.erl:449: :erl_eval.expr/5
remote:     (stdlib) erl_eval.erl:126: :erl_eval.exprs/5
remote:     (elixir) lib/code.ex:240: Code.eval_string/3
remote:     (mix) lib/mix/config.ex:158: anonymous fn/2 in Mix.Config.__import__!/2
remote:     (elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
remote:     (mix) lib/mix/config.ex:157: Mix.Config.__import__!/2
remote: The command '/bin/sh -c mix deps.get' returned a non-zero code: 1
remote: 
remote: Verifying deploy...
remote: 
remote: !	Push rejected to serene-tor-13468.
remote: 
To https://git.heroku.com/serene-tor-13468.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/serene-tor-13468.git'

Most Liked

outlog

outlog

think the issue will be solved if you complete these steps: phoenix/guides/deployment/releases.md at main · phoenixframework/phoenix · GitHub

perzanko

perzanko

Have you set up database on your Heroku app? ‘DATABASE_URL is missing’ means that you haven’t exported the environment variable. You probably didn’t add a database as addon on Heroku.

If you use postgres, here is the tutorial how to do it: Heroku Postgres | Heroku Dev Center

biske

biske

That’s ok, but my question is not about buildpack deploy, but container one. Whole point is that there is Phoenix documentation how to deploy which doesn’t work.

Where Next?

Popular in Questions Top

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
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
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 39297 209
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement