EthioDeploy
DocsPricingDomainsBlogToolsChangelog
Deploy guides/Socket.IO

Host a Socket.IO server

A Socket.IO server deploys like any Node.js web app: create one HTTP server, attach Socket.IO to it, and listen on 0.0.0.0 and process.env.PORT. WebSockets pass through the platform's proxy with no extra setting. The Free plan works for trying it, but it sleeps after 30 minutes without new HTTP requests, and that closes every open socket. Pro ($10 a month) keeps the server on all the time.

Last updated November 29, 2026

What we run by default
Detected by
package.json
Install
npm ci / pnpm / yarn (from your lockfile)
Build
npm run build (if you have one)
Start
npm start

These run automatically, so leave the command fields blank. Only override them in Settings → Build if you need something different.

Fix this first: Answer 200 on / as well as on /socket.io/

Socket.IO only handles requests under /socket.io/. Every deploy checks your health check path (/ by default) and only goes live on a 2xx or 3xx, so a bare Socket.IO server that returns 404 on / never goes live. Add a plain route for /, as in the example below, or set a different Health Check Path in Settings.

Write the server

A minimal chat server. package.json:

{
  "name": "socket-server",
  "type": "module",
  "scripts": { "start": "node server.js" },
  "dependencies": { "socket.io": "^4.8.4" }
}

server.js creates a normal Node HTTP server, attaches Socket.IO to it and listens on the port the platform sets:

import { createServer } from "node:http";
import { Server } from "socket.io";

const httpServer = createServer((req, res) => {
  // The health check requests "/" and needs a 2xx.
  if (req.url === "/" || req.url === "/healthz") {
    res.writeHead(200, { "Content-Type": "text/plain" });
    res.end("ok");
    return;
  }
  res.writeHead(404).end();
});

const io = new Server(httpServer, {
  // Only needed when the page that connects is on another domain.
  cors: { origin: process.env.CORS_ORIGIN?.split(",") ?? false },
});

io.on("connection", (socket) => {
  socket.on("chat message", (msg) => {
    io.emit("chat message", msg);
  });
});

const port = Number(process.env.PORT) || 3000;
httpServer.listen(port, "0.0.0.0", () => {
  console.log(`listening on 0.0.0.0:${port}`);
});

process.on("SIGTERM", () => {
  io.close(() => process.exit(0));
});

The same file works with Express: pass the server from createServer(app) to new Server() and call listen on that server, not on app. The SIGTERM handler lets the server close its sockets when a deploy replaces it. This server used 44 MB of memory with one client connected when we ran it under the Free plan's 256 MB limit, so memory isn't the constraint for a small app.

Connect from the browser

If the page that connects is served by the same app, call io() with no URL. If the frontend lives somewhere else (a Vercel site, another project, localhost while you develop), connect to the server's address:

import { io } from "socket.io-client";

const socket = io("https://<project-slug>.ethiodeploy.app");
socket.on("chat message", (msg) => console.log(msg));
socket.emit("chat message", "hello");

Use the https:// address. The client switches to wss:// for the WebSocket itself. Then allow the frontend's origin by setting CORS_ORIGIN in the project's env vars, comma-separated:

CORS_ORIGIN=https://www.example.com,http://localhost:5173

Socket.IO's docs say CORS only applies to the HTTP long-polling requests a client sends before it upgrades to a WebSocket, but those come first, so a missing origin stops the connection before the WebSocket is ever tried.

What happens to open connections on a deploy

Each push builds a new container. Once it passes the health check, new requests go to it and the old container is stopped, which sends it SIGTERM and gives it 10 seconds. Sockets open on the old container close at that point.

Clients don't need code for this. Socket.IO's client reconnects by default, without a retry limit, waiting 1 second at first and at most 5 seconds between tries, and it lands on the new container. What does get lost is anything the server kept in memory, such as rooms and the list of who's online. Rejoin rooms in the client's connect handler and keep anything that matters in a Postgres or Redis addon.

Sticky sessions and the Redis adapter

Socket.IO's docs call for sticky sessions and an adapter when one app runs as several server processes: long-polling requests from one client have to reach the same process, and a broadcast has to reach clients connected to the others. Each EthioDeploy project runs as a single container, so all of a client's requests reach the same process and io.emit() reaches every connected client. You don't need either. The flip side is that there is no setting to run more copies of the same server.

On Pro, a project can also run services: more web services or background workers from the same repo, each in its own container with its own start command. A Next.js app and a Socket.IO server can live in one repo that way, the socket server at <project-slug>-<name>.ethiodeploy.app. A worker that needs to push an event to clients can call the socket server over the project's private network. Every service gets a variable with each web service's internal address, such as SERVICE_SOCKET_URL for a service named socket. The route the worker calls is also reachable through the public address, so check a shared secret from your env vars before acting on it.

Can I host a Socket.IO server for free?

The Free plan costs nothing and needs no card. It includes:

  • One project, live over HTTPS at <project-slug>.ethiodeploy.app.
  • 256 MB of memory and half a CPU core.
  • A managed Postgres, MySQL or Redis addon with 512 MB of storage. It doesn't expire.
  • A redeploy on every push, the same as the paid plans.

The catch is sleep. After 30 minutes without traffic the app stops, and the next request starts it again. We hold that request for up to 30 seconds while the app boots, so the first visitor after a quiet spell waits a little.

For a socket server the sleep rule matters more than usual. We count activity from HTTP requests passing through the proxy, and a WebSocket only shows up there when it closes. Socket.IO's heartbeat (a ping every 25 seconds) travels inside the open WebSocket, so it doesn't count. If nobody opens a page or a new connection for 30 minutes, the app is stopped even with clients connected, and every socket closes.

The clients then reconnect on their own. Their first request is a normal HTTP long-polling request, which wakes the app, and the connection comes back once it has started. A client created with transports: ["websocket"] skips polling, and its first attempt after a sleep can fail while the app starts. The next retry connects. Free is fine for a demo or a side project. For chat or live dashboards that people keep open, use Pro.

When the app has to stay awake or needs your own domain, Pro is $10 or 1,399 ETB a month: always on, 1 GB of memory and a 5 GB database.

Deploy

  1. Sign in with GitHub and install the EthioDeploy app on the repo.
  2. Click “New Project” and pick the repo.
  3. Watch the build in the dashboard. When the health check passes, your app is live at <project-slug>.ethiodeploy.app. Every push to the default branch redeploys, and the old version keeps serving until the new one is healthy.

Troubleshooting

The deploy fails its health check, but the logs say the server started+

Cause: The server listens on localhost or a fixed port, or / returns 404 because only Socket.IO handles requests.

Fix: Listen on 0.0.0.0 and process.env.PORT, and answer 200 on / (or set your own Health Check Path).

The browser console shows a CORS error or "xhr poll error"+

Cause: The page is on another origin and the server doesn't allow it, so the long-polling handshake is blocked.

Fix: Add the page's exact origin (scheme, host and port) to CORS_ORIGIN and redeploy.

Every client disconnects and reconnects when I push+

Cause: A deploy replaces the container, and sockets on the old one close when it stops.

Fix: This is expected. The client reconnects by itself. Rejoin rooms in the connect handler and keep state in a database, not in memory.

Connections drop after about 30 minutes with users still connected (Free plan)+

Cause: Open WebSockets don't count as activity, so the app went to sleep.

Fix: Move the project to Pro, which never sleeps.

Rooms or the online list are empty after a deploy+

Cause: They lived in the old process's memory.

Fix: Store them in Postgres or Redis and rebuild them as clients reconnect.

The browser blocks the connection as mixed content+

Cause: An HTTPS page is connecting to an http:// address.

Fix: Connect to https://<project-slug>.ethiodeploy.app.

Still stuck? Check the deployment's build log in the dashboard, or see Troubleshooting.

Questions

Yes, on the Free plan with no credit card: 256 MB of memory, half a CPU core and a free Postgres or Redis addon. A small Socket.IO server used about 44 MB in our test. The app sleeps after 30 minutes without new HTTP requests, and open WebSockets don't count, so connected clients are dropped and reconnect when it wakes. Pro ($10 a month) keeps it always on.

Yes, with no setting. Socket.IO's polling handshake upgrades to a WebSocket through the proxy, and in our test through the same proxy version the platform runs, a WebSocket stayed open for 150 seconds and still received messages. The same applies to the ws package and other WebSocket servers on the app's port.

No. Those are for running several server processes. A project runs as one container, so every request from a client reaches the same process and io.emit() reaches every connected client.

The new version takes new connections once it passes its health check, then the old container is stopped and its sockets close. Socket.IO clients reconnect automatically, retrying every 1 to 5 seconds, and land on the new version. Anything the server held in memory, like rooms, is gone.

On Pro, yes: add it as a service in the same project. It builds from the same repo with its own start command and gets its own address. On the Free plan you get one project with one process, so the socket server would have to run inside your web app's process.

Ready to deploy?

Sign in with GitHub and pick your repo. No Dockerfile, no YAML.

More guides

Firebase StudioReplitv0

All guides on the deploy guides page. Custom domains, env vars, addons and billing are in the docs.

On this page
Write the serverConnect from the browserWhat happens to open connections on a deploySticky sessions and the Redis adapterCan I host a Socket.IO server for free?DeployTroubleshootingQuestions
Deploying with an agent?Point it at llms.txt. Every guide is in one file there.Open llms-full.txt →
EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiPayload CMSDjangoDjango + CeleryFastAPIFlaskStreamlitExpressNestJSSocket.IOLaravelRailsGoSpring BootASP.NET CoreTelegram botDiscord botWhatsApp botn8nLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy