My node.js app is getting an Unhandled 'error' event randomly on writing requests after I


I am running node.js(0.8.20 and 0.9.10) on windows 2012 server. I have ran it absolutely without any problems for weeks. That was without Nginx(1.2.6) in front. With nginx in front configured like this:

#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream dem2 { server; } server { listen 80; server_name dem2.cz dem2; access_log /nginx-1.2.6/logs/dem2.log; location / { #proxy_pass; proxy_pass http://dem2/; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } } server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } } }

On requests, I randomly get this error in Node.js app:

events.js:69 throw arguments[1]; // Unhandled 'error' event ^ Error: socket hang up at createHangUpError (http.js:1383:15) at ServerResponse.OutgoingMessage._writeRaw (http.js:499:26) at ServerResponse.OutgoingMessage._send (http.js:466:15) at ServerResponse.OutgoingMessage.end (http.js:911:18) at SendStream.notModified (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:223:7) at SendStream.send (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:353:17) at SendStream.pipe (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:322:10) at Object.oncomplete (fs.js:93:15) Process finished with exit code 1

I suspect I have something wrong configured in Nginx, but I sure as hell don't know what it could be. Could anyone advise please?

I can post the node.js code too if you want, but it is nothing fancy, just 100 line express app for serving AngularJS static files with the option to serve HTML generated in PhantomJS when there is a bot.


There was a bugfix in 0.8.20 which significantly raised the number of "http hang-up" errors you get. They talk about it in the <a href="http://blog.nodejs.org/2013/02/15/node-v0-8-20-stable/" rel="nofollow">release notes</a>. As @robertkelp said, it's nothing to worry about, but you should catch error events emitted by the http server to avoid crashing the server.


  • Polymer Starter Kit with Node, Express, and Puppeteer
  • 502 bad gateway nginx shiny file upload
  • Downloading a file using Django
  • node js express app serve static files
  • How to serve js file that needs to be executed on client side?
  • Reduce memory consumption in PHP while handling uploads by php input
  • django download file from server to user's machine,or read online
  • How to run .php script on node.js
  • Converting byte array output into Blob corrupts file
  • android progressbar
  • Restler Returns Always Not Found With Or Without Index.php
  • Express sending assets with wrong MIME type
  • Nothing is being shown while there's no error. The code is working fine
  • ngix and php5-fpm blank page
  • 404 on Socket.io connect
  • Find the operating system of web app's client
  • .htaccess Rewrite url with images from a folder to a php file
  • xsendfile won't work with mod_rewrite
  • trim url query string with .htaccess
  • Fatal error: Call to undefined function add_filter() in index.php in Wordpress
  • PHP code to determine if a user was 301 redirected to my site
  • Missing Content-Length header when using Nginx + Gzip + Unicorn
  • .htaccess allow only from Chrome, Opera, Mozilla, Safari, redirect from others
  • search text only using Java
  • Building Node.JS on Solaris: “Use of is valid only in a c99 compilation environment.”
  • Linux sendfile source
  • How can I get the screen size of mobile devices when they hit my web server?
  • Design(Classes, methods, interfaces) of real time applications(server/client)
  • Django login form in bootstrap popup
  • Obtain actual browser URL in PHP
  • How do I get the list of bad records that didn't load in Bigquery?
  • SQL Query - Table Joining Problems
  • Can't remove headers after they are sent
  • How to use JavaScript to determine whether a file exists in a directory?
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Benchmarking RAM performance - UWP and C#