How do I use websockets on an app

I’m making a server with a DO app.

Websockets aren’t working (Firefox can’t establish a connection to the server)

Is it because of the port? How can I allow the port through? I tried making it 8080 (defined in my app spec as the http port), but that didn’t work. Tried making it a random port number, but that didn’t work either.

Are websockets blocked somehow? Do I need to allow the port somehow?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I’m having the same problem with a Droplet project. I’ve tried downloading the repository that njw suggested and modify it with no result. I’ve also done some experimenting with express-ws. It works locally, but I can’t deploy to the DigitalOcean server.

I get the “Firefox can’t establish a connection to the server” as well. Made me wonder if there’s some special combination of ip and port you should hit, and if it should be allowed in firewall, nginx, or similar.

Does anyone know how to fix it?

Take into account the “HTTP Request Route” that you’ve set up for your Web Service.

If your server exists at:**API**

Your WebSocket connection now exists on the “API” namespace.

This means you will connect to your WebSocket server using:


If you’re using you can read about it here:

Hey there!

Services that you run on the App Platform are exposed via app domains on port 443/HTTPS. So you should use the wss:// scheme when connecting. This is not necessarily the same port as you would specify that your service is listening on internally.

We have a sample nodejs repo that uses websockets and can be forked + deployed to the App Platform without any changes if that helps as a reference:

Hope that helps! Nate