# Connection refused with DigitalOcean droplet on HTML

**URL:** <https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414>\
**Category:** Local Setup\
**Tags:** getting-started, sdk-defold\
**Created:** [March 3, 2021, 5:04pm UTC](https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414 "2021-03-03T17:04:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/totebo/32/528_2.png) [@totebo](https://forum.heroiclabs.com/u/totebo)\
**Post date:** [March 3, 2021, 5:04pm UTC](https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414/1 "2021-03-03T17:04:49Z")

</div>

Hey, I’m new around here. 👋

I’m using Defold to create a test game using Nakama as a backend for a real-time client authoritative game. Everything works as it should when testing locally within the Defold IDE, but when bundled to HTML5 I get this error:

```
WebSocket connection to 'ws://142.93.41.41/ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2OWI2ZGMxMC0zODE3LTQ3ZTItOWFlMS1kYTkzODJiZjY2NjQiLCJ1c24iOiJudkdCVHVKdWpsIiwiZXhwIjoxNjE0NzY4MzIzfQ.tSGf0HKb59dMgYjIHF7GnVPrjmB3vadXN3SaDIEbles' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

```

I’m running the Nakama instance from a DigitalOcean Nakama droplet. I’ve changed the config file Nakama uses to be ready for production, but that doesn’t seem to make any difference. Are there additional steps to configure a websocket connection when the client connects from a web browser?

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [March 3, 2021, 10:05pm UTC](https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414/2 "2021-03-03T22:05:46Z")

</div>

@totebo Hi there! Looks like the connection is being refused, and `ERR_CONNECTION_REFUSED` usually means there wasn’t even a server on the other end accepting traffic on that port so the target machine refused it completely.

This usually happens when you’re trying to use the wrong port. You’re trying to establish a WebSocket connection on port 80, are you sure this is correct? The server by default listens on 7350 so unless you’ve changed that in the server config you should update your connection settings in the client.

---

<div class="post-metadata">

**Author:** ![totebo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/totebo/32/528_2.png) [@totebo](https://forum.heroiclabs.com/u/totebo)\
**Post date:** [March 3, 2021, 10:53pm UTC](https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414/3 "2021-03-03T22:53:34Z")

</div>

Hi, thanks for the response! I’ve configured Defold to port 7350 and there are no errors when connecting from Defold IDE.

Looking at the error you’re right - the port is missing from the call, so it probably defaults to 80, which is not configured to accept connections.

I’ll do some more digging tomorrow. Cheers!

**Update** : Changing the Nakama server and client to run on port 80 fixes the issue. My best guess is that the Defold websocket/Nakama integration for some reason defaults to port 80 even though a different port is specified in the Defold config. I’ve also posted this on the [Defold forums](https://forum.defold.com/t/creating-online-games-using-nakama-and-defold/67687/18).

---

<div class="post-metadata">

**Author:** ![totebo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/totebo/32/528_2.png) [@totebo](https://forum.heroiclabs.com/u/totebo)\
**Post date:** [March 12, 2021, 3:53pm UTC](https://forum.heroiclabs.com/t/connection-refused-with-digitalocean-droplet-on-html/1414/4 "2021-03-12T15:53:29Z")

</div>

A final update on this: The [Defold Websocket extension](https://github.com/defold/extension-websocket/releases) has been updated which now allows any port to be used on HTML. 🥳
