cowboy


Start Phoenix app with cowboy server on different port


Is it possible to start locally a few Phoenix apps on different ports from the console using some command like mix phoenix.server --port=4001? This one does not work, of course, but, maybe, there is similar way.
Yep! Make sure you set the mix config to reference the env port, i.e.
config :my_app, MyApp.Endpoint,
http: [port: {:system, "PORT"}],
Then from the terminal:
$ PORT=4001 mix phoenix.server
$ PORT=4002 mix phoenix.server
$ PORT=4003 mix phoenix.server
Edit your config/dev.exs and change the Endpoint http port like the following:
config :my_app, MyApp.Endpoint,
http: [port: System.get_env("PORT") || 4000],
This allows the port to be set, or left as the default 4000:
PORT=4002 mix phoenix.server # to run on port 4002
mix phoenix.server # to run on port 4000
This answer was described by #chris-mccord on github.
This was needed for me as a solution since my issue was that I needed to let C9.io dictate the port, for me, adding this code to the dev.exs file solved the problem:
config :my_app, MyApp.Endpoint,
http: [port: {:system, "PORT"}],
and then in the Terminal, I just needed to run the server as normal:
mix phoenix.server

Related Links

why the cowboy as httpclient can't start inets
Start Phoenix app with cowboy server on different port

Categories

HOME
c#
msbuild
compression
casting
postsharp
cryengine
coordinates
xss
checkpoint
richtextbox
aggregate-functions
install
revit-api
mamp
logstash-configuration
samba
google-calendar-api3
airbnb
audio-streaming
gpo
connectiq
google-drive-android-api
ng-tags-input
sha
windows-mobile
jopendocument
stack-trace
spock
dynamics-ax-2012-r3
recreate
semantic-ui-react
key-bindings
visual-studio-debugging
keil
slim-lang
visual-prolog
postgresql-9.6
favorites
ragel
azure-storage-files
device-driver
strategy-pattern
kepserverex
observer-pattern
icu
pyexcel
autodesk-data-management
ocpjp
encoder
spring-webflow-2
opos
fckeditor
cc
nsalert
multi-select
group
computed-properties
particle-system
audiorecord
database-administration
nonblocking
gtkwave
magnet-uri
notice
glog
screen-lock
asp.net-2.0
firebase-tools
chrome-mobile
iphone-6
uiblureffect
frisby.js
jsonschema2pojo
growl
parsefloat
oxygenxml
ccmenuitem
parallel-port
angular-file-upload
behance-api
ant-contrib
farpoint-spread
pthreads-win32
carrier
vbaccelerator
xcode6.1-gm-seed
angularjs-select2
phone-state-listener
feincms
orchestration
openafs
xcode4.6.3
google-email-audit-api
sup
reflexil
advanceddatagrid
wdm
xpolog
qvariant
zipstream
nstoolbar
lts

Resources

Encrypt Message