Recommended Free Tools
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
Most WebSocket failures on an Ubuntu VPS fall into one of four faults: NGINX is not forwarding the HTTP upgrade, the public URL or path is wrong, NGINX cannot reach the application, or an idle connection is being closed by a timeout. Fix them in that order. Confirm the exact ws:// or wss:// endpoint, configure NGINX to proxy HTTP/1.1 with explicit Upgrade and Connection headers, prove the backend works locally, then set an idle-timeout and heartbeat policy.
What a WebSocket connection needs to succeed
A WebSocket starts as an HTTP/1.1 request. The client asks to switch protocols with an Upgrade: websocket header and a matching Connection: Upgrade header. A successful server response is 101 Switching Protocols; after that response, the connection becomes a bidirectional WebSocket stream.
NGINX treats Upgrade as a hop-by-hop header. It therefore does not forward that header to an upstream server automatically. The reverse proxy must use HTTP/1.1 upstream and set both upgrade-related headers explicitly. NGINX documents this WebSocket tunnel behavior for responses that return status 101 and requests that ask for a protocol switch.
That distinction makes the first diagnosis straightforward:
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
- A 400, 426, or immediate close usually means the handshake reached a server but the URL, headers, origin policy, or application handshake is wrong.
- A 502 Bad Gateway or connection refusal usually means NGINX cannot connect to the configured backend.
- A connection that works and then closes after roughly 60 seconds is commonly an idle read timeout. NGINX documents 60 seconds as the default
proxy_read_timeoutwhen no data is received. - A TLS error or protocol-version complaint points to the public certificate, SNI/server-block selection, or a mismatch between the protocol used by NGINX and the protocol the backend actually serves.
1. Confirm the endpoint and protocol first
Copy the client URL character for character before editing NGINX. Check the hostname, path, port, and query string. A WebSocket route is not automatically the same as the HTTP route that serves your web page; for example, an application may expect /socket/ while the client is attempting / or /ws.
Choose ws:// or wss:// deliberately
- Use
ws://only when the endpoint is intentionally unencrypted, such as a private test listener. - Use
wss://when the public listener is HTTPS. The certificate must cover the hostname in the URL, and the request must select the intended NGINX TLS server block.
If the browser page itself was loaded over HTTPS, browsers generally block an unencrypted ws:// connection as mixed content. A certificate that is valid for a different name, an incorrect SNI match, or an HTTPS listener pointed at a plain-HTTP upstream can all look like a generic WebSocket failure even though the application is running.
Check the path and server block
Make sure the location prefix in NGINX matches the client path, including trailing-slash behavior. Confirm that the hostname resolves to this VPS and that the request reaches the server block whose server_name matches it. Testing an IP address while the certificate and configuration are for a DNS name can select a different block and produce misleading TLS or 404 results.
2. Configure NGINX for the WebSocket upgrade
Put the map in the http context, not inside a server or location block. Then use a location dedicated to the WebSocket route. This pattern assumes the application listens on plain HTTP at 127.0.0.1:3000 and the public endpoint is HTTPS on port 443.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
server_name example.com;
location /socket/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 300s;
}
}
Why each directive matters
| Directive | Purpose | Typical failure if missing or wrong |
|---|---|---|
proxy_pass |
Selects the backend host, port, and protocol. | Connection refusal or 502 when the target is stopped, unreachable, or uses the wrong protocol. |
proxy_http_version 1.1 |
Uses HTTP/1.1 between NGINX and the application so the upgrade can be carried upstream. | The client reaches NGINX, but the upstream never performs a WebSocket upgrade. |
proxy_set_header Upgrade $http_upgrade |
Copies the client’s upgrade request to the upstream. | The application receives an ordinary HTTP request instead of a WebSocket handshake. |
proxy_set_header Connection $connection_upgrade |
Sends Connection: upgrade when the client requested an upgrade and close otherwise. |
Handshake rejection or an upstream that closes the request immediately. |
proxy_read_timeout |
Controls how long NGINX waits for upstream data after the connection is established. | Quiet sessions close at the default 60-second interval or at another shorter network timer. |
Use the backend’s real protocol in proxy_pass. If the application serves HTTPS rather than HTTP, the target must use https:// and its certificate and TLS settings must be valid from NGINX’s point of view. Do not add HTTPS merely because the public URL is wss://; TLS can terminate at NGINX while the private hop remains plain HTTP.
3. Validate and load the configuration safely
- Check syntax and referenced files:
sudo nginx -t - Reload without dropping existing worker processes:
sudo systemctl reload nginx - Inspect the complete active configuration, including included files, when the file you edited does not appear to take effect:
sudo nginx -T
If nginx -t reports an error, fix that error before reloading. Common causes include placing map in the wrong context, a misspelled directive, an unbalanced brace, or a certificate path that does not exist. If the test passes but behavior is unchanged, nginx -T can reveal that another server block or an earlier, more specific location is handling the request.
4. Prove the backend works on the VPS itself
Do not change firewall rules until you know the service is listening and healthy. Run these checks on the Ubuntu host:
sudo ss -ltnp | grep ':3000'
curl -i http://127.0.0.1:3000/health
sudo systemctl status your-websocket-service
sudo journalctl -u your-websocket-service -n 100 --no-pager
sudo tail -f /var/log/nginx/error.log
Interpret the local checks
- If
ssshows no listener, the application is stopped, crashed during startup, listening on another port, or bound to an unexpected address. - If the health request fails locally, fix the application before debugging NGINX. A failed local request cannot be repaired by adding proxy headers.
- If the service listens only on a different interface or port, make
proxy_passmatch that address, or change the application’s bind setting deliberately. - If the health request succeeds but NGINX returns 502, compare the exact host and port in
proxy_passwith the listener shown byss. Also check permissions, local firewall policy, and the NGINX error log.
A service bound to 127.0.0.1 is reachable by NGINX on the same VPS and is not directly exposed to the internet. A service bound to an unexpected private or public address can instead be unreachable from NGINX or unnecessarily exposed.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
5. Match the symptom to the failure layer
| Observed result | Most likely layer | Checks to perform |
|---|---|---|
| 400, 426, or immediate close | Handshake, URL, or application policy | Verify path and query string, HTTP/1.1 upstream, both upgrade headers, origin policy, and application handshake logic. |
| 502 Bad Gateway | NGINX-to-backend connection | Check that the service is running, listening on the configured port, reachable from the NGINX host, and using the protocol named by proxy_pass. |
| Connection refused | No process accepting the target socket | Use ss -ltnp, inspect systemd status and journal output, and correct the address or port. |
| 404 from the application | Wrong route or location mapping | Compare the client path with the application’s WebSocket route and review how the location prefix is passed upstream. |
| Connects, then closes near 60 seconds | Idle timeout | Set an appropriate proxy_read_timeout and send ping frames more frequently than the shortest idle timer in the path. |
| TLS error, certificate warning, or wrong-version message | Public TLS or protocol mismatch | Check certificate hostname coverage, SNI/server-block selection, listener port, and whether the upstream is HTTP or HTTPS. |
6. Fix idle disconnects with coordinated timeouts and heartbeats
Increasing one timeout is not enough if another hop has a shorter timer. A client, browser or mobile network, NAT device, firewall, CDN, cloud load balancer, and NGINX may each enforce their own idle limit. Identify the shortest timer on the actual route.
NGINX’s documented default is a 60-second proxy_read_timeout when no data arrives from the upstream. Set the value longer than the quiet period your application needs, as in proxy_read_timeout 300s;, and reload NGINX. Then configure the WebSocket server to send protocol-level ping frames at an interval safely below that timeout. The heartbeat must produce traffic; merely extending the proxy setting does not keep an entirely silent connection alive through other network devices.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choose values from the application behavior
- For an interactive session that should never be silent for more than a few seconds, use a heartbeat comfortably below every known idle limit.
- For a connection that may be quiet for minutes, choose a longer proxy timeout but retain periodic pings so NAT and firewall state remains active.
- When you cannot control an intermediary’s timer, design the client to reconnect cleanly and resume state rather than assuming the socket is permanent.
Do not confuse a heartbeat failure with a handshake failure. A connection that receives HTTP 101 and exchanges messages has already completed the upgrade; investigate timers, ping handling, and application lifecycle rather than adding more upgrade headers.
7. Check TLS termination and the private protocol
With wss://, TLS protects the public client-to-NGINX connection. NGINX may then proxy to a plain HTTP WebSocket server on localhost, which is common on a single VPS. In that design, the public listener needs the certificate and TLS configuration, while proxy_pass remains http://.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
If the application itself serves TLS, use https:// in proxy_pass and configure the trust and certificate expectations required for that private connection. A mismatch such as sending HTTPS to a plain-HTTP port, or HTTP to a TLS port, commonly generates reset, handshake, or “wrong version” errors. Verify both ends independently: test the public certificate and confirm which protocol the backend actually speaks.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse the intended hostname
Certificate validation depends on the hostname, not merely the VPS IP address. Ensure the certificate covers the exact name in the wss:// URL and that DNS points that name to this server. If several HTTPS virtual hosts share an address, SNI determines which certificate and server block NGINX selects.
8. Review application and Node.js behavior
NGINX can be correctly configured while the application rejects the request. Inspect application logs for an unexpected path, rejected origin, authentication failure, malformed subprotocol, or a process that exits after accepting a socket.
For Node.js backends, review the HTTP server’s timeout settings as well as WebSocket-library options. Node’s HTTP API exposes configurable header and connection timeout behavior; an overly short value can reset or close a socket even when NGINX’s read timeout is long. Look for socket errors, header-timeout messages, forced Connection: close behavior, and uncaught exceptions in the service journal.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Make sure the application returns a normal HTTP response for its health endpoint and performs the WebSocket upgrade only on the intended route. A health check that succeeds does not prove that the upgrade path, origin policy, authentication, or heartbeat code is correct, but it does establish that the process is reachable.
9. Run the service under supervision
A manually started process may disappear when the shell closes, after a crash, or during a reboot. Run the application under systemd or an equivalent supervisor, configure restart-on-failure, and set its working directory and environment explicitly. The service definition must use the same port, bind address, credentials, and runtime version that you tested interactively.
- Use
sudo systemctl status your-websocket-serviceto see whether systemd considers the process running. - Use
sudo journalctl -u your-websocket-service -n 100 --no-pagerto find startup failures, missing environment variables, and runtime exceptions. - After changing a unit file, reload systemd’s unit definitions, restart the service, and verify the listener again with
ss.
Keep the application on a local or private listener when NGINX is the public entry point. Exposing the application port directly creates a second path that may bypass TLS, authentication, rate limits, and the logging you rely on at the proxy.
10. A repeatable repair runbook
- Reproduce with the exact URL. Record hostname, path, query string, scheme, and the observed status or browser error.
- Classify the failure. Separate an immediate handshake error from a later idle disconnect; separate 502/refusal from 400/426.
- Verify the listener. Run
sudo ss -ltnpfor the configured backend port and check the service state and journal. - Test locally. Call the application’s health endpoint on
127.0.0.1or its actual bind address. - Inspect NGINX. Confirm the matching server block, location, upstream protocol, HTTP/1.1, and both upgrade headers with
sudo nginx -T. - Apply safely. Run
sudo nginx -t, thensudo systemctl reload nginx; watch/var/log/nginx/error.logwhile reconnecting. - Resolve TLS separately. Confirm certificate hostname coverage and SNI, then verify that the private protocol matches the backend’s listener.
- Address idle behavior. Set a read timeout appropriate for the path and enable application ping frames below the shortest intermediary timer.
- Retest after each change. Change one layer at a time so the successful fix is identifiable and can be applied consistently to other locations.
How to choose between two possible fixes
When more than one change appears plausible, compare them on four axes:
- Failure location: client URL, TLS listener, NGINX proxy, backend process, or an intermediate network device.
- Failure timing: before HTTP 101, immediately after the handshake, or after an idle period.
- Scope: one
location, one virtual host, or every NGINX server block. - Change type: proxy-only configuration versus an application change such as heartbeat support, origin handling, or reconnect logic.
Prefer the narrowest change that addresses the proven layer. A location-specific header or timeout avoids changing unrelated virtual hosts; an application heartbeat is necessary when the application must keep traffic flowing through a network timer, while a proxy-only timeout change cannot create traffic by itself.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
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.

