---
title: "WebSockets and Fly"
description: "Fly supports WebSocket connections, and the post demonstrates that support with flychat-ws, a small chat application built from raw WebSockets and Express. Deployment requires cloning the example, running npm install, then using flyctl init, flyctl deploy, and flyctl open, with no application-specific configuration changes. Its fly.toml maps internal TCP port 8080 to HTTP port 80 and TLS/HTTP port 443, sets concurrency limits of 20 soft and 25 hard, and checks the service every 10 seconds with a two-second timeout. The Node server broadcasts each received message to every connected client, while the browser selects ws or wss from the served protocol and sends JSON messages. TLS terminates at Fly’s network edge, and the app can also run locally or in Docker."
---

# WebSockets and Fly

[Fly.io](https://yomu.fyi/company/fly-io) · May 20, 2020

**Type:** Tutorial

## Summary

Fly supports WebSocket connections, and the post demonstrates that support with flychat-ws, a small chat application built from raw WebSockets and Express. Deployment requires cloning the example, running npm install, then using flyctl init, flyctl deploy, and flyctl open, with no application-specific configuration changes. Its fly.toml maps internal TCP port 8080 to HTTP port 80 and TLS/HTTP port 443, sets concurrency limits of 20 soft and 25 hard, and checks the service every 10 seconds with a two-second timeout. The Node server broadcasts each received message to every connected client, while the browser selects ws or wss from the served protocol and sends JSON messages. TLS terminates at Fly’s network edge, and the app can also run locally or in Docker.

## Context

The post addresses whether Fly supports WebSocket connections and uses a chat application to demonstrate long-lived, bidirectional messaging on the platform.

## Approach / What changed

It deploys the flychat-ws example with flyctl, using an Express server and the ws library, a fly.toml service definition, and a Dockerfile that sets PORT=8080. The client chooses ws or wss based on the served protocol, while the server broadcasts incoming JSON messages to all connected clients.

## Takeaways

- fly.toml routes external HTTP traffic on port 80 and TLS/HTTP traffic on port 443 to the application’s internal TCP port 8080.
- The WebSocket server uses its maintained client list to broadcast each incoming message to every connected client, including the sender.
- TLS is terminated at Fly’s network edge, so the application handles traffic through its regular application port without special TLS connection code.

**Tags:** [Docker](https://yomu.fyi/topic/docker), [Express](https://yomu.fyi/topic/express), [Fly.io](https://yomu.fyi/topic/fly-io), [WebSockets](https://yomu.fyi/topic/websockets)

- Source: [Fly.io](https://fly.io/blog/websockets-and-fly)
- Source URL: https://fly.io/blog/websockets-and-fly
- Ingested by Yomu: 2026-09-02T11:57:19.487Z

[Read original post](https://fly.io/blog/websockets-and-fly)
