Hi every one.

We have celery app on python, some time we got error "ConnectionError: Error 110 connecting to localhost:6379. Connection timed out."

On our system ipv6 disabled, so connect to localhost posible only via ipv4

that is our config cat /etc/redis/redis.conf |grep -v '^#'| grep -v '^$' daemonize yes pidfile /var/run/redis/redis-server.pid port 6379 tcp-backlog 65536 bind 127.0.0.1 timeout 0 tcp-keepalive 0 loglevel debug logfile /var/log/redis/redis-server.log databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /var/lib/redis slave-serve-stale-data yes slave-read-only yes repl-disable-tcp-nodelay no slave-priority 100 maxclients 100000 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes

in log file we don't see any error or warning about connection or max open files limit, who can help find us what is problem?

Comment From: itbdw

I just solved this problem today!

You really should set the timeout to a reasonable seconds, not the default 0. Both tcp-keepalive should be set, for example 60s is nice.

You can check the detail progress from my blog, Fix Redis 110 'connection timed out' problem

@antirez I highly suggest change the default timeout to a none zero value. Also this timeout confused the people first using Redis. They may think the timeout stands for connection timeout or execute timeout, and they may think it's ok not set timeout.

So when client crashed for any reason, the redis still hold the idle connection forever. It seems when client create a new connection to redis server when there is still idle connection, it returns '110 connection timed out', is that the point?

Comment From: rezaxd

Hello dear @itbdw . I think timeout and tcp-keepalive are for after connection established. But error 110, says that connection is not established. We first need to create a connection then talk about these 2 parameters. Am I right?

Comment From: yossigo

@rezaxd You are correct, the keepalive and timeout configuration affects open connections. The original problem reported here involves a connection timeout on the client side. It could still be indirectly related to a server side issue, like a very high load and connection rate resulting with accept() not catching up, but such extreme conditions are probably best analyzed on a case by case basis.

Closing this issue as it's not strictly a redis-server problem.