The following in your
...makes both http://example.com and https://example.com go to 127.0.0.1, hence: your own machine. (Even more: anything that refers to
example.com, such as
telnet would go to 127.0.0.1 when run from your computer.)
Apparently you have a web server running on your own computer on port 80 (HTTP), but nothing on port 443 (HTTPS). Even more, getting
ERR_CONNECTION_REFUSED actually proves your
hosts file is used, as otherwise you would see the default website from https://example.com.
Note that if you would have the server on your computer also support HTTPS on port 443, you'd get certificate errors, as there is no way you can buy a certificate for the domain