Skip to content
Browse files

If port zero is specified, Redis will not listen for TCP connections

  • Loading branch information...
1 parent 71791e7 commit a36d524562a7f6d2e344c0aff3a2ea06a36199bb @antirez committed Feb 7, 2011
Showing with 5 additions and 1 deletion.
  1. +1 −0 redis.conf
  2. +4 −1 src/redis.c
View
1 redis.conf
@@ -21,6 +21,7 @@ daemonize no
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379.
+# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
# If you want you can bind a single interface, if the bind option is not
View
5 src/redis.c
@@ -852,7 +852,10 @@ void initServer() {
createSharedObjects();
server.el = aeCreateEventLoop();
server.db = zmalloc(sizeof(redisDb)*server.dbnum);
- server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr);
+
+ if (server.port != 0)
+ server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr);
+
if (server.ipfd == ANET_ERR) {
redisLog(REDIS_WARNING, "Opening port: %s", server.neterr);
exit(1);

0 comments on commit a36d524

Please sign in to comment.
Something went wrong with that request. Please try again.