Sometimes I need to share network address of my machine with my colleague which have access to same network(same wifi). and its really useful if he can connect to my machine and perform queries/requests from their machine eg when I run a vue project, it prints:
and I can share this network address with my colleagues and they can access web app on my machine. I am wondering if I can get this network address in phoenix app. Thanks
In development mode the application binds only to 127.0.0.1 (or ::1 on IPv6 enabled systems) if I recall correctly. This is to avoid some bad player in the network ruining your development effort by attacking your application.
In general it is considered good practice to have development on localhost only.
If you want to open this up, you have to specify the IP to bind to manually. There is nothing in phoenix what would try to autodetect what it could possibly bind to.
And thats a good thing, as a single computer can have many interfaces and each interface could have many IP addresses.
You do not want to expose an in development software on the wrong IP to the wrong network.
PS: You can totally bind to 0.0.0.0/::, but you should be aware of the consequences, and you still need to manually check your systems interfaces for the IP you want to hand to your co-workers.
Thanks @NobbZ. and I understand this as well. But if I get my inet address using ifconfig on ubuntu(I am not sure if this is different on mac or Windows), I can still connect to my server from other machines on the same network so nothing stopping me already. I just want to get that inet address from the system and on server start print it on the screen(development machine) and if I needed will share it with my colleague who is on the same network
Given the phoenix generators were just changed to bind to localhost only (and therefore only to a single interface) I doubt this can make it into phoenix itself. You could however alias phx.server and run a custom mix task after phoenix started doing your own logging.