# inets example missing ssl:start()

**URL:** <https://erlangforums.com/t/inets-example-missing-ssl-start/2821>\
**Category:** Chat / Discussions\
**Tags:** documentation, inets\
**Created:** [August 22, 2023, 10:52pm UTC](https://erlangforums.com/t/inets-example-missing-ssl-start/2821 "2023-08-22T22:52:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frumiousj](https://erlangforums.com/letter_avatar_proxy/v4/letter/f/8797f3/32.png) [@frumiousj](https://erlangforums.com/u/frumiousj)\
**Post date:** [August 22, 2023, 10:52pm UTC](https://erlangforums.com/t/inets-example-missing-ssl-start/2821/1 "2023-08-22T22:52:19Z")

</div>

In [Erlang -- HTTP Client](https://www.erlang.org/doc/apps/inets/http_client), if I follow the instructions (without using a proxy because I don’t need a proxy here), erl hangs when making a request to [http://www.erlang.org](http://www.erlang.org).

```erlang
johnk@dirtynewcomputer:~$ erl
Erlang/OTP 26 [erts-14.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V14.0 (press Ctrl+G to abort, type help(). for help)
1> inets:start().
ok
2> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} =
.. httpc:request(get, {"http://www.erlang.org", []}, [], []).

BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a

```

That’s because after this documentation was written, [http://www.erlang.org](http://www.erlang.org) now redirects to [https://www.erlang.org](https://www.erlang.org), which requires `ssl:start().`

e.g.

```erlang
johnk@dirtynewcomputer:~$ erl
Erlang/OTP 26 [erts-14.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V14.0 (press Ctrl+G to abort, type help(). for help)
1> inets:start().
ok
2> ssl:start().
ok
3> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request(get, {"http://www.erlang.org", []}, [], []).
{ok,{{"HTTP/1.1",200,"OK"},
     [{"cache-control","public,max-age=0,must-revalidate"},
      {"date","Tue, 22 Aug 2023 22:21:43 GMT"},
      {"accept-ranges","bytes"},
      {"age","11450"},
      {"etag","\"1050519f47cb36b79741a041558c101d-ssl\""},
      {"server","Netlify"},
      {"content-length","19144"},
      {"content-type","text/html; charset=UTF-8"},
      {"strict-transport-security","max-age=31536000"},
      {"x-nf-request-id","01H8FNDT5CBS2Q7GZNXX92MD59"}],
     "<!DOCTYPE html>\n<html lang=\"en\">\n\n\n\n<head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\n
...

```

Given that these days, more and more sites are moving to https-only mode, and redirecting http to https (like [www.erlang.org](http://www.erlang.org) does) should `inets:start()` actually include `ssl:start().` or equivalent? Or just update the documentation for inets?

Thanks,

- johnk

---

<div class="post-metadata">

**Author:** ![starbelly](https://erlangforums.com/user_avatar/erlangforums.com/starbelly/32/209_2.png) [@starbelly](https://erlangforums.com/u/starbelly)\
**Post date:** [August 22, 2023, 10:56pm UTC](https://erlangforums.com/t/inets-example-missing-ssl-start/2821/2 "2023-08-22T22:56:11Z")

</div>

It actually does redirect. httpc by default has `autoredirect` set to `true`, so it may _appear_ that it’s not ,but if you set this to `false` …

```erlang
1> httpc:request(get, {"http://www.erlang.org", []}, [{autoredirect, false}], []).
{ok,{{"HTTP/1.1",301,"Moved Permanently"},
     [{"date","Tue, 22 Aug 2023 22:54:56 GMT"},
      {"location","https://www.erlang.org/"},
      {"server","Netlify"},
      {"content-length","38"},
      {"content-type","text/plain; charset=utf-8"},
      {"x-nf-request-id","01H8FQAM9AKAWYXX3GVW1VG43R"}],
     "Redirecting to https://www.erlang.org/"}}

```

🙂

---

<div class="post-metadata">

**Author:** ![frumiousj](https://erlangforums.com/letter_avatar_proxy/v4/letter/f/8797f3/32.png) [@frumiousj](https://erlangforums.com/u/frumiousj)\
**Post date:** [August 22, 2023, 11:19pm UTC](https://erlangforums.com/t/inets-example-missing-ssl-start/2821/3 "2023-08-22T23:19:35Z")

</div>

Thanks Bryan,

My point is that the `inets` documentation of that example does not say anything about setting `autoredirect` to `false`, nor does it suggest to `ssl:start()` (which is what worked for me, and does follow the redirect, which I actually want).

Furthermore, the example would work, as written, if `inets:start()` also included `ssl:start()`, which is an intriguing (to me) possibility since so many sites these days redirect to https, and/or only offer their sites over https, so it could or even should be the default to start ssl at the same time as inets.

Cheers,

- johnk

---

<div class="post-metadata">

**Author:** ![starbelly](https://erlangforums.com/user_avatar/erlangforums.com/starbelly/32/209_2.png) [@starbelly](https://erlangforums.com/u/starbelly)\
**Post date:** [August 22, 2023, 11:30pm UTC](https://erlangforums.com/t/inets-example-missing-ssl-start/2821/4 "2023-08-22T23:30:18Z")

</div>

Right, so perhaps there’s enhancements to make to the docs. To note, ssl should be started up for you, but if this isn’t clear, then perhaps it should be documented at least somewhat.
