Deployment on Heroku - iex shell problem

Hello everyone! I’m quite excited since this is my first post on ElixirForum yay!
Okay so let’s get to the point.

I have created some hobby application on Heroku. I was using this guide here https://hexdocs.pm/phoenix/heroku.html
My application is container one, using Dockerfile looking like this:

FROM elixir:1.10.1-alpine as build

RUN apk add --update git build-base

WORKDIR /app

RUN mix local.hex --force && \
    mix local.rebar --force

ENV MIX_ENV=prod
ADD . .
RUN mix deps.get
RUN mix deps.compile

RUN mix release

# prepare release image
FROM alpine:3.9 AS app
RUN apk add --update bash openssl

WORKDIR /app

COPY --from=build /app/_build/prod/rel/<app_name> .

CMD ["./bin/<app_name>", "start"]

So basically everything works great, the application is running but the problem is when I want to connect to my application by IEx shell.

heroku run "./bin/<app_name> remote"

After that I just receive information that

Could not contact remote node <app_name>@187ca8de-f25e-4555-bf9d-eb4a8d3e6649, reason: :nodedown. Aborting...

I’m wondering what’s the case here. I saw on this Heroku docs, that when using buildpack there is a possibility to connect via iex -S mix of course but in my case when I run the application in a container that’s no go.

Maybe there is no possibility to connect to that app because of how Heroku dynos are working. I don’t know that and this is the case why this post was created :joy:

I would appreciate any help, thank you!

I haven’t used heroku recently, but I ran into a similar problem just now while working with a phoenix app release running in a docker container. In my case it was because I was trying to launch the console with docker run but I needed to use docker exec because the nodes can’t communicate across different container instances. From what I recall my guess is heroku run creates a new container to run the command in.

That isn’t possible with the regular heroku run call. It will always spin up a new container, so there isn’t anything to connect to.

You can take a look at Heroku Exec, which may provide a way to SSH tunnel in (but all the examples are for Java):

2 Likes