[erlang-questions] Unable to access my inets http server from my phone or external PC

Ioannis Pinakoulakis giannis.pin@REDACTED
Mon Mar 2 23:54:20 CET 2015


Basically, 0.0.0.0 means that it will bind on any available netwprk interface on the local machine. Visiting the link you will find a more complete explanation why this happens.

http://serverfault.com/q/78048

/Ioannis

1 mar 2015, 22:20, ο/η austin aigbe <eshikafe@REDACTED> έγραψε:

> Thanks Thomas.
> 
> Changing the bind_address to 0.0.0.0 solved the issue.
> 
> Surprisingly, the python server is also using 0.0.0.0 and I did not even notice it.
> 
> C:\Users\eausaig>python -m SimpleHTTPServer
> Serving HTTP on 0.0.0.0 port 8000 ...
> 
> 
> Working version:
> 
> -module(web_server).
> -export([start/0, stop/0]).
> 
> -define(PORT, 8000).
> -define(SERVER_NAME, "server1").
> -define(ROOT,"C:/Users/eausaig/Desktop/web_server").
> 
> start() ->
> inets:start(),
> {ok, _} = inets:start(httpd, 
> 						[{port, ?PORT},
> 						 {server_name,?SERVER_NAME}, 
> 						 {server_root,?ROOT},
> 						 {document_root,?ROOT},
> 						 {bind_address,{0,0,0,0}},
> 						 {directory_index,["index.html"]},
> 						 {server_tokens, full}]).
> 
> stop() ->
> 	[{_,_},{_,P2}] = inets:services(),
> 	ok = inets:stop(httpd, P2).
> 
> BR,
> Austin
> 
> 
> 
> bind_address,{127,0,0,1} should be bind_address,{0,0,0,0}. 127.0.0.1 is the loopback interface and only receives connections from the same host which is why you can't connect from other devices.
> 
> -- 
> Thomas van Neerijnen
> +4477 1709 7670
> 
>> On Sun, Mar 1, 2015 at 1:26 AM, Leonard Boyce <leonard.boyce@REDACTED> wrote:
>> Removing the bind_address or set it to a non-localhost IP which is bound to your machine should sort it out.
>> 
>> Leonard
>> 
>>> On Feb 28, 2015 6:19 PM, "austin aigbe" <eshikafe@REDACTED> wrote:
>>> Hi,
>>> 
>>> I can't seem to access the erlang inets http server (web_server.erl) from my Android phone (using http://<PC IP address>:8000) via WiFi
>>> 
>>> However, I am able to access the python based simpleHTTPServer from my Android phone (using http://<PC IP address>:8000) via WiFi.
>>> 
>>> How do I make my erlang inets server accessible from an external PC or phone?
>>> 
>>> OS: Windows 7
>>> 
>>> %-----------------------
>>> % web_server.erl
>>> %-------------------------
>>> -module(web_server).
>>> -export([start/0, stop/0]).
>>> 
>>> -define(PORT, 8000).
>>> -define(SERVER_NAME, "server1").
>>> -define(ROOT,"C:/Users/eausaig/Desktop/web_server").
>>> 
>>> start() ->
>>> {ok, _} = inets:start(httpd, 
>>> 						[{port, ?PORT},
>>> 						 {server_name,?SERVER_NAME}, 
>>> 						 {server_root,?ROOT},
>>> 						 {document_root,?ROOT},
>>> 						 {bind_address,{127,0,0,1}},
>>> 						 {directory_index,["index.html"]},
>>> 						 {server_tokens, full}]).
>>> 
>>> stop() ->
>>> 	[{_,_},{_,P2}] = inets:services(),
>>> 	ok = inets:stop(httpd, P2).
>>> 
>>> BR,
>>> Austin
>>> 
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150302/4fcf4e55/attachment.htm>


More information about the erlang-questions mailing list