erlanginets

How to start inets in Erlang?


{ok, Pid} = inets:start(httpd, [{port, 0},
2>       {server_name,"httpd_test"}, {server_root,"/tmp"},
2>       {document_root,"/tmp/htdocs"}, {bind_address, "192.168.0.31"}]).
** exception error: no match of right hand side value {error,{failed_determine_ip_address,"192.168.0.31",inet6fb4,
                                                                                          nxdomain}}

When I tried starting inets as above, I get an error message. Why does that happen? I copied & pasted from the API doc, but I still can't start inets. How can I solve this?


Solution

  • Try specifying the bind address as {bind_address, {192,168,0,31}} instead. If you pass a string, inets thinks it is a hostname, and tries to resolve it, failing with nxdomain.