Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-11-29 11:20:21 +0300
committerRyan Dahl <ry@tinyclouds.org>2010-11-29 11:20:21 +0300
commit7a7feb8cd344725a0d164b94f4500a1118c60d5b (patch)
treee7d104d2307c7f8a1052c1b5b31fcef2ced60124 /doc
parent105501c1958c1faff8a467c6d00ffb52457f427e (diff)
Add note about EADDRINUSE to docs
Diffstat (limited to 'doc')
-rw-r--r--doc/api/net.markdown17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/api/net.markdown b/doc/api/net.markdown
index 62947d627a3..7b69a2986d8 100644
--- a/doc/api/net.markdown
+++ b/doc/api/net.markdown
@@ -66,6 +66,23 @@ IPv4 address (`INADDR_ANY`).
This function is asynchronous. The last parameter `callback` will be called
when the server has been bound.
+One issue some users run into is getting `EADDRINUSE` errors. Meaning
+another server is already running on the requested port. One way of handling this
+would be to wait a second and the try again. This can be done with
+
+ server.on('error', function (e) {
+ if (e.errno == require('constants').EADDRINUSE) {
+ console.log('Address in use, retrying...');
+ setTimeout(function () {
+ server.close();
+ server.listen(PORT, HOST);
+ }, 1000);
+ }
+ });
+
+(Note: All sockets in Node are set SO_REUSEADDR already)
+
+
#### server.listen(path, [callback])
Start a UNIX socket server listening for connections on the given `path`.