<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>port Archives | Programming Zen</title>
	<atom:link href="https://programmingzen.com/tag/port/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/tag/port/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Thu, 07 May 2020 17:50:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">1397766</site>	<item>
		<title>Specify a Port when Booting a Phoenix Application</title>
		<link>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/</link>
					<comments>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Mon, 04 May 2020 00:16:48 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cowboy]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[elixir-cookbook]]></category>
		<category><![CDATA[phoenix]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[sever]]></category>
		<category><![CDATA[tips]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2474</guid>

					<description><![CDATA[<p>When developing a Phoenix application, you&#8217;ll boot the server with: mix phx.server. This will start Cowboy in development mode, which by default accepts connections on port 4000. But how do you specify a different port? In Phoenix, there is no -P or -p option. You&#8217;ll need to edit your config/dev.exs configuration file to change the host key as follows: System.get_env(&#34;PORT&#34;, &#34;4000&#34;) retrieves the value of the PORT environment variable if one has been set. If the environment doesn&#8217;t have the specified variable (i.e., PORT), it will default to 4000. You can then boot your Phoenix server by passing the variable </p>
<p>The post <a href="https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/">Specify a Port when Booting a Phoenix Application</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When developing a Phoenix application, you&#8217;ll boot the server with: <code>mix phx.server</code>. This will start Cowboy in development mode, which by default accepts connections on port <code>4000</code>. But how do you specify a different port? In Phoenix, there is no <code>-P</code> or <code>-p</code> option.</p>



<p>You&#8217;ll need to edit your <code>config/dev.exs</code> configuration file to change the <code>host</code> key as follows:</p>



<pre class="wp-block-code"><code>http: &#91;port: System.get_env("PORT", "4000")],</code></pre>



<p><code>System.get_env("PORT", "4000")</code> retrieves the value of the <code>PORT</code> environment variable if one has been set. If the environment doesn&#8217;t have the specified variable (i.e., <code>PORT</code>), it will default to <code>4000</code>.</p>



<p>You can then boot your Phoenix server by passing the variable value to the command as follows:</p>



<pre class="wp-block-code"><code>$ PORT=5000 mix phx.server</code></pre>



<p>This will run the server on the port you specified, in this example <code>5000</code>.</p>



<p>The name of the environment variable is arbitrary. We used <code style="font-size: 16px;">PORT</code> but we could have opted for <code style="font-size: 16px;">PHX_PORT</code> or something else altogether. Just so long as your configuration file and environment use the same name.</p>



<p>You can, of course, set the environment variable outside of the <code>mix phx.server</code> command, for example in your shell profile.</p>
<p>The post <a href="https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/">Specify a Port when Booting a Phoenix Application</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2474</post-id>	</item>
	</channel>
</rss>
