Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Deploy a Socket.IO Node.js App With Dokku on a VPS

A practical Dokku deployment guide for Socket.IO: prepare the Node app, declare the web process, verify Dokku’s port mapping, configure nginx for /socket.io/ upgrades, and troubleshoot polling, 502, timeout, and scaling problems.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable pattern is simple: run your Node.js app as Dokku’s web process, let the app listen on Dokku’s assigned port, and configure nginx to pass the WebSocket upgrade on /socket.io/. The upgrade requires HTTP/1.1 plus the Upgrade and Connection headers. For connections that remain open, increase nginx’s read timeout. Treat the port setting as a version-specific check rather than blindly adding PORT=3000.

This guide walks through preparing the app, creating the Dokku app, deploying it, configuring the proxy, testing both polling and WebSocket transports, and diagnosing the failures that are specific to Socket.IO behind Dokku.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the finished deployment looks like

A browser connects to your VPS over HTTPS. Dokku’s nginx receives the request and normally forwards ordinary HTTP traffic to the Node process. Socket.IO starts with an HTTP request to /socket.io/ and may then request an upgrade to WebSocket. nginx must preserve that upgrade instead of treating it as an ordinary HTTP request.

The request path through the system is:

  1. Client resolves your hostname to the VPS address.
  2. nginx, managed by Dokku, accepts HTTP or HTTPS.
  3. The nginx location handling /socket.io/ forwards HTTP/1.1 and the upgrade headers to the app.
  4. Dokku routes the request to the app’s web process.
  5. The Node.js server listens on the port Dokku assigned inside the container.

A missing web process, an incorrect internal port, or a proxy that drops the upgrade can each produce a deployment that appears healthy while Socket.IO fails.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites

  • A VPS with a supported Linux distribution and a public IP address.
  • Dokku installed and reachable over SSH. Installation and TLS commands differ by Dokku release, so use the documentation for the exact version installed on your VPS.
  • A DNS name whose A or AAAA record points to the VPS.
  • A local Node.js project that starts successfully with a production command.
  • SSH access for the Dokku administrative user and a local Git client.
  • A firewall allowing SSH and the HTTP/HTTPS ports you intend to expose.

Do not begin by hard-coding a public port in the application. Dokku’s port-management guidance says that Dokku derives the application port from its port mappings; manually setting PORT can conflict with that behavior. Confirm the rule in your installed Dokku version before changing configuration.

Prepare the Socket.IO application

Create an HTTP server and attach Socket.IO

Socket.IO should be attached to the same HTTP server that serves your web routes. A minimal CommonJS entry point looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const http = require('http');
const express = require('express');
const { Server } = require('socket.io');

const app = express();
app.get('/health', (req, res) => res.status(200).send('ok'));

const server = http.createServer(app);
const io = new Server(server, {
  // Keep the default path unless your client is configured differently.
  path: '/socket.io/'
});

io.on('connection', (socket) => {
  socket.emit('ready', { id: socket.id });
  socket.on('message', (payload) => {
    io.emit('message', payload);
  });
});

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

The fallback value is useful for local development. In Dokku, the process should use the value supplied through the environment. Binding to 0.0.0.0, rather than only 127.0.0.1, allows the Dokku proxy to reach the process inside the container.

Use a production start script

Your package.json should expose the command that starts the server:

{
  "scripts": {
    "start": "node server.js"
  }
}

Run npm install and npm start locally, then verify that http://localhost:3000/health returns ok and that a Socket.IO client can connect. A local success does not prove that nginx is forwarding upgrades, but it separates application errors from proxy errors.

Add the required Procfile

Create a file named exactly Procfile (capital P, no extension) in the repository root:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
web: npm start

Dokku’s process management model uses the web process type for incoming web traffic. On the first deployment, Dokku normally scales that process type to one instance. If the Procfile calls the process something else, the app can build successfully without receiving web requests.

Create the Dokku application

Log in to the VPS as the Dokku administrator and create an app name. Replace my-socket-app with the name you want to use:

dokku apps:create my-socket-app

Set a hostname so Dokku can generate the nginx server block for the app:

dokku domains:set my-socket-app socket.example.com

Domain and TLS command names have changed across Dokku releases and plugins. If either command is not recognized, use the matching domain-management instructions for your installed release rather than substituting an unrelated nginx configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the deployment transport

Dokku commonly accepts a Git push over SSH. The exact remote syntax depends on the SSH user and the branch you deploy, so confirm it against your Dokku version. A typical workflow is:

git remote add dokku [email protected]:my-socket-app
git push dokku main

If your repository’s production branch is named master, push that branch instead. Watch the build output for the Node buildpack, dependency installation, process formation, and the final proxy status. A successful Git push means the image was built; it does not by itself prove that WebSocket upgrades work.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Handle the application port correctly

Port handling is the part most likely to differ between Dokku versions and deployment recipes.

Situation What to do
Application reads process.env.PORT Preferred. Let Dokku provide the internal port through its proxy and container configuration.
A guide tells you to run dokku config:set APP PORT=3000 Do not copy it automatically. Some third-party instructions use this pattern, while Dokku’s port-management guidance advises against manually setting PORT. Verify the installed release first.
Legacy port-map example Older examples use a setting such as DOKKU_PROXY_PORT_MAP=http:80:5000. Treat this as version- and configuration-specific, not a universal Socket.IO requirement.

After deployment, inspect the app’s reported proxy and process configuration with the Dokku commands available in your release. The important invariant is that the Node process listens on the same internal port Dokku forwards to. If logs show the app listening on 3000 while Dokku forwards to another port, fix the mapping or the app configuration; do not expose a random additional public port.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure nginx for the WebSocket upgrade

Dokku generates nginx configuration, so avoid editing generated files directly: a rebuild, deploy, or configuration change can overwrite them. Use Dokku’s supported nginx customization mechanism for your release, or add the directives through the app’s nginx template/customization facility.

Dedicated Socket.IO location

The essential location must use HTTP/1.1 and forward the upgrade headers:

location /socket.io/ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_buffering off;
    proxy_read_timeout 600s;
    proxy_pass http://my-socket-app-web;
}

The upstream name in a Dokku-generated configuration is release-dependent; do not paste my-socket-app-web unless that is the upstream name your generated file uses. The three upgrade directives are the non-negotiable part:

  • proxy_http_version 1.1 keeps the upstream connection on HTTP/1.1, which supports the upgrade.
  • proxy_set_header Upgrade $http_upgrade forwards the client’s requested protocol upgrade.
  • proxy_set_header Connection "upgrade" tells the upstream that the connection should be upgraded.

Turning buffering off is recommended for the dedicated WebSocket location. A long-lived connection also needs a read timeout longer than nginx’s commonly observed default of about 60 seconds; otherwise an otherwise idle connection can be dropped. Choose a timeout appropriate for your application, such as 600 seconds, and test reconnection behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

One location for HTTP and WebSocket traffic

If you want the same location to handle ordinary HTTP and upgrades, nginx can derive the Connection value from the request’s Upgrade header:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

location / {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_buffering off;
    proxy_read_timeout 600s;
    proxy_pass http://my-socket-app-web;
}

A dedicated /socket.io/ location is easier to reason about when you are debugging. The single-location pattern is useful when your nginx customization system makes separate locations difficult, but ensure the map is declared in the nginx configuration context where your release permits it.

Deploy, then verify in layers

  1. Check the process log. Use Dokku’s app log command for your release and confirm that the Node process starts, binds to the expected port, and does not exit immediately.
  2. Check plain HTTP. Request https://socket.example.com/health. A 200 response proves DNS, the hostname, the proxy route, and the web process are functioning for ordinary HTTP.
  3. Check the Socket.IO polling endpoint. Request the Socket.IO path with the query parameters generated by your client. A response from the Engine.IO handshake indicates that the route reaches the application. Do not assume that a 404 on a guessed URL is meaningful; Socket.IO’s query string and protocol version are part of the handshake.
  4. Check the browser’s WebSocket request. In developer tools, open Network, filter for WS, and reload the page. The request should target /socket.io/ and show a successful protocol switch. If it remains in polling, inspect the upgrade headers and the client/server Socket.IO version compatibility.
  5. Test an idle connection. Leave a client connected longer than the old proxy timeout and then send an event. If it disconnects without an application error, increase proxy_read_timeout and reload the proxy through Dokku’s supported mechanism.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and precise fixes

HTTP works, but WebSocket upgrade fails

Symptoms include a successful page load, repeated polling requests, or a browser error during the upgrade. Check the nginx location first. All three upgrade requirements must be present: HTTP/1.1, the Upgrade header, and Connection "upgrade". Confirm that the location actually matches /socket.io/; a more general location or a path mismatch can bypass the directives.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The app returns 502 or “connection refused”

This normally means nginx cannot reach the web process. Inspect the process log for a crash, verify that the Procfile contains web: npm start, and compare the port on which Node is listening with Dokku’s configured internal port. Remove an unverified manual PORT setting if it conflicts with Dokku’s mapping, then redeploy.

The deployment succeeds but there is no web route

Check that the app has a web process and that it is scaled to one or more instances. A worker-only Procfile does not receive HTTP traffic. Also verify the hostname assigned to the app and that DNS points to this VPS.

Connections close after roughly a minute

An nginx read timeout near 60 seconds is a common cause of idle WebSocket disconnects. Set a longer proxy_read_timeout in the Socket.IO location, reload the configuration using Dokku’s supported method, and test an idle connection again. The timeout only affects the proxy; application-level heartbeat and client reconnection settings still matter.

Polling works but the client never upgrades

Confirm that the client uses the same Socket.IO path as the server, normally /socket.io/, and that the public URL is HTTPS when the page is HTTPS. Mixed-content blocking can prevent the connection before nginx sees it. If the path and scheme are correct, inspect the generated nginx configuration for a competing location that omits the upgrade headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scaling beyond one instance

A single web process is the least complicated deployment: every handshake and subsequent connection reaches the same instance. When you scale to multiple instances, treat session affinity as an architectural requirement to investigate, not an automatic Dokku feature. Socket.IO’s long-polling fallback can send successive requests that need to reach the same session; the search material available for this guide does not establish how a particular Dokku release configures sticky sessions. Before scaling, decide whether to force WebSocket-only transport, configure a compatible shared adapter and session strategy, or keep one instance until you have verified affinity and cross-instance event delivery.

Scaling also changes operational checks: test reconnects during a rolling deploy, verify that all instances use the same application and Socket.IO versions, and confirm that a broadcast emitted on one instance reaches clients connected to another.

TLS, restarts, and operational hygiene

Serve the production site over HTTPS so browsers permit secure WebSocket connections. Configure certificates using the TLS method supported by your Dokku version and certificate plugin; do not hand-edit generated nginx files. After enabling TLS, use an https:// application URL and allow the client library to derive the secure WebSocket scheme.

  • Keep the Node start command deterministic and commit the lockfile used by your package manager.
  • Expose a lightweight health endpoint that does not require a Socket.IO session.
  • Review logs after every deploy and after every nginx customization.
  • Set a deliberate Socket.IO ping/reconnection policy in the application; proxy timeouts are not a substitute for heartbeats.
  • Document the Dokku version and the exact port mapping so a future upgrade does not silently invalidate a hand-written setting.

Deployment checklist

  • The server binds to process.env.PORT and 0.0.0.0.
  • package.json has a working production start script.
  • The repository root contains Procfile with web: npm start.
  • The Dokku app has the intended domain and at least one web process.
  • Port configuration matches the installed Dokku version; no conflicting manual PORT value remains.
  • nginx forwards HTTP/1.1, Upgrade, and Connection "upgrade" for /socket.io/.
  • Buffering is disabled for the WebSocket location and the read timeout covers your expected idle period.
  • The health endpoint returns 200 through the public hostname.
  • Browser developer tools show a successful WebSocket upgrade, not only polling.
  • Scaling and sticky-session behavior have been tested before adding instances.

Frequently Asked Questions

Can I use a different Socket.IO path than /socket.io/?

Yes. Set the same custom path in the Socket.IO server and client, then change the nginx location to match it. The proxy headers and HTTP/1.1 requirement remain the same.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I force WebSocket transport to avoid sticky sessions?

Only after testing your client and infrastructure. Forcing WebSocket removes the long-polling fallback, but it also removes a useful compatibility path and does not solve every multi-instance session problem.

Why does changing an nginx file on the VPS sometimes have no effect?

Dokku generates and reloads nginx configuration. Direct edits can be replaced by a deploy or configuration change; use the customization mechanism supported by your Dokku release and then trigger its documented reload.

Is a 200 response from /health enough to declare success?

No. It verifies ordinary HTTP routing only. You must also observe the Socket.IO handshake and a successful WebSocket upgrade in the browser network panel.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.