<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="10688" data-post-id="10688">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nobody" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nobody
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>thank you Stefan for that suggestion, this is a very good idea!<br>
I wish you a very nice sunday, too!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="10688" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-10688" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="10688"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="10689" data-post-id="10689">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Cowboy does bind to 0.0.0.0 (aka all interfaces) per default and cowboy is the web server used by phoenix.</p>
<p>As I already mentioned in <a href="https://forum.elixirforum.com/t/how-to-bind-phoenix-app-to-specific-ip-address/1702/2" class="inline-onebox" rel="nofollow">How to bind phoenix app to specific ip address? - #2 by NobbZ</a> you can of course change the IP to bind to. And as you can set a config, you can ask for its value as well.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="10689" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-10689" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="10689"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="10690" data-post-id="10690">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nobody" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nobody
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>you are right, sysasi - I should have asked more detailed, so really everybody can understand it!</p>
<p>So to be very exact I would like to get the IP address to which phoenix binds to automatically when it is run, I jsut wanted to add a quick debug statement in my template for this, but then it turns out that it evolves into a major task.</p>
<p>Of course in the end it is much more important to be able to bind phoenix to a specific ip address, please see my other question about that from today, thank you very much!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="10690" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-10690" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="10690"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="57913" data-post-id="57913">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="joe" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/joe/120/5064_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  joe
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If anyone else is looking for it’s own IP address and finds this thread.. In my nerves project I use <code>:inet.getif/0</code> and loop through the result until I find one that fits my pattern (e.g. one that starts with 192.168).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="57913" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-57913" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="57913"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="200731" data-post-id="200731">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PJUllrich" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PJUllrich/120/15944_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PJUllrich
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Building Table Views with Phoenix LiveView</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just a side note: If you cannot get your “real world” IP with <code>:inet.getif/0</code>, then you might want to consider making a HTTP-Request to <a href="https://httpbin.org/ip" rel="noopener nofollow ugc">https://httpbin.org/ip</a>, which simply returns your request-IP.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="200731" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-200731" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="200731"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="266121" data-post-id="266121">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="blackham" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/blackham/120/9322_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  blackham
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>A way to make a good guess at your server IP. (It might not be your public IP if you have NAT). Sadly I couldn’t find a way for erlang to return a list of the network routes, so I had to fall back to a System.cmd call. The idea is find the default gateway for the server, see what dev (interface) it us using, then find the IP addr of that device.</p>
<p>I promise there are better ways to do this that will work with ipv6, not rely on a System.cmd (like read /proc), handle multiple IPs assigned to the same device, etc.. but its’ quick and dirty and works for me.:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Get the name of the default interface (IF)
# Wish erlang hand a command to nicely get the route information
#   Could work with `netstat -rn` too with some changes to the regex
{result, 0} = System.cmd("ip", ["route","list","default"])
default_if = Regex.scan(~r/.*dev (.*) .*/U, result, capture: :all_but_first) |&gt; List.first |&gt; List.first |&gt; String.to_charlist

# Now find the default device in the list of all devices
{:ok, ifs} = :inet.getifaddrs
{_if, attrs} = List.keyfind(ifs, default_if, 0)

# Now grab the IP in {a,b,c,d} format
{:addr, ip} = List.keyfind(attrs, :addr, 0)

# Now make it a string (sorry, binary BitString.. whatever)
{a,b,c,d} = ip
"#{a}.#{b}.#{c}.#{d}"
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="266121" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/how-to-get-the-server-ip-address/1700/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-266121" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="266121"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>