vrod

vrod

Connect to running app with iex?

We have an elixir app running in prod. I can SSH onto this box, but is it possible to connect to the app with an iex session? When I run ./bin/foobar start_iex I get an error:

Protocol 'inet_tcp': the name foobar@ip-1-2-3-4.ec2.internal seems to be in use by another Erlang node

I know something about --cookie and --sname to connect to a session, but I do not know how the prod app was started. Is it possible to know the cookie or session from bash command line? And is better to SSH onto box or to connect to remote iex session directly from my local computer?

Thanks you!

Marked As Solved

RudManusachi

RudManusachi

In this case I guess you can simply bin/foobar remote.

start_iex starts the system and attaches iex shell. Since application is already started it won’t allow you start it again with the same name.

And is better to SSH onto box or to connect to remote iex session directly from my local computer?

While remsh might look like a convenient option that allows to run :observer etc.. Please take a look at “Erlang’s remsh is dangerous”.

Personally so far I’m satisfied with bin/release_name remote. Plus phoenix_live_dashboard replaces most of the :observer I use.

Also Liked

RudManusachi

RudManusachi

Hi @dodo! and welcome to the community.
One way you could achieve that is:
Modify systemd service so it starts the application with the name (e.g. prod):
elixir --sname prod -S mix phx.server

Now we can connect to it from the same machine with:
iex --remsh prod --sname dev

I’ve never run this way in production, though.. not sure if this is idiomatic =)

vrod

vrod

Thank you, this worked exactly!

And thank you for the security link!

dodo

dodo

How can I achieve this when I’m not using releases? Specifically, a phoenix app started with mix phx.server by a systemd service.

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
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement