# Hosting an HTML via golang webserver

**URL:** <https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402>\
**Category:** App requests and development\
**Created:** [4 February 2024 17:11 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402 "2024-02-04T17:11:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fzed](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@fzed](https://syncloud.discourse.group/u/fzed)\
**Post date:** [4 February 2024 17:11 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402/1 "2024-02-04T17:11:43Z")

</div>

I have a small golang app that creates an HTML file and hosts it:

```auto
func startHttpServer() {
	port := ":8089"
	dirname := "html"
	fs := http.FileServer(http.Dir(dirname))
	mux := http.NewServeMux()
	mux.Handle("/", fs)
	log.Fatal(http.ListenAndServeTLS(port, "/var/snap/platform/current/syncloud.crt", "/var/snap/platform/current/syncloud.key", mux))
}

```

… and it _almost_ works. Connecting to `https://<local-ip>:8089/file.html` works. The page is displayed as expected. (As you can see I use Syncloud’s certificate, so I have to confirm that I trust the page because the certificate is only valid for `<name>.syncloud.it`, but then it works.)  
However, connecting from outside via my actual URL does not work: `https://<name>.syncloud.it:8089/file.html` shows this error message in Firefox:

> Secure Connection Failed  
> An error occurred during a connection to [name].syncloud.it:8089. PR\_END\_OF\_FILE\_ERROR  
> Error code: PR\_END\_OF\_FILE\_ERROR

And this is what Chrome displays:

> This site can’t be reached  
> The connection was reset.  
> Try:
> 
> - Checking the connection
> - Checking the proxy and the firewall
> 
> ERR\_CONNECTION\_RESET

`curl` reports an SSL error:

```auto
curl -v https://[name].syncloud.it:8089/file.html
* Host [name].syncloud.it:8089 was resolved.
* IPv6: (none)
* IPv4: [public-ip]
* Trying [public-ip]:8089...
* Connected to [name].syncloud.it ([public-ip]) port 8089
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: none
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to [name].syncloud.it:8089 
* Closing connection
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to [name].syncloud.it:8089

```

Any idea what’s wrong?  
Cheers!

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [5 February 2024 08:38 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402/2 "2024-02-05T08:38:20Z")

</div>

Hi,

Is port 8089 visible outside your bome network?  
Do you see different curl response on 8090 (non existent for sure) for example?

---

<div class="post-metadata">

**Author:** ![fzed](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@fzed](https://syncloud.discourse.group/u/fzed)\
**Post date:** [6 February 2024 17:47 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402/3 "2024-02-06T17:47:03Z")

</div>

Yes, I enabled that port. When disabled:

```auto
curl -v https://[name].syncloud.it:8089/file.html
* Host [name].syncloud.it:8089 was resolved.
* IPv6: (none)
* IPv4: [public-ip]
* Trying [public-ip]:8089...
* Connected to [name].syncloud.it ([public-ip]) port 8089
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: none
* Recv failure: Connection reset by peer
* OpenSSL SSL_connect: Connection reset by peer in connection to [name].syncloud.it:8089 
* Closing connection
curl: (35) Recv failure: Connection reset by peer

```

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [6 February 2024 17:57 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402/4 "2024-02-06T17:57:51Z")

</div>

Ok it is hard to say without trying it myself.  
Do you have the same version of ip (6 or 4) on both ends (router and machine your are running curl on)?  
You could send the url to the support email so I can check.

---

<div class="post-metadata">

**Author:** ![fzed](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@fzed](https://syncloud.discourse.group/u/fzed)\
**Post date:** [6 February 2024 18:53 UTC](https://syncloud.discourse.group/t/hosting-an-html-via-golang-webserver/402/5 "2024-02-06T18:53:43Z")

</div>

Oh Jesus, I figured it out!  
Turns out port 8089 is not viable for IPv6 _and_ IPv4 for some reason. My router only opened port 8089 for IPv6 and silently opened a different port for IPv4. Hence, I couldn’t connect via IPv4 on that port …  
I don’t remember why I chose 8089, probably randomly. Apparently, it is reserved or something.

Thanks a lot – one more time – Boris, for the fast support! 🚀 Your question about IPv4/IPv6 brought me on the right track, this has been bugging me for WEEKS.
