I can't get Redis to work as I want it to. I have configured two Servers, a MASTER (10.0.2.15) and a SLAVE (10.0.2.7)

My config on the MASTER: (/etc/redis/redis.conf)

maxmemory 4gb
maxmemory-policy allkeys-lru
supervised systemd
appendonly yes
bind 127.0.0.1 10.0.2.15

My SLAVE config: (/etc/redis/redis.conf)

maxmemory 4gb
maxmemory-policy allkeys-lru
supervised systemd
appendonly yes
slaveof 10.0.2.15 6379

After this configuration the two Servers synchronize, the slave is read only. And the MASTER is in Reading writing. Everything is normal here.

The problem happens when I reboot the MASTER, slave can no longer synchronize on his own after the MASTER reboot, in the SALVE logs I have this message:

After MASTER reboot on SLAVE log file : (/var/log/redis/redis-server.log)

568: S 06 Feb 2020 11: 36: 01.797 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 02.804 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 02.805 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 02.805 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 03.809 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 03.810 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 03.811 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 04.815 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 04.816 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 04.817 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 05.822 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 05.823 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 05.824 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 06.828 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 06.829 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 06.830 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 07.837 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 07.838 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 07.838 # Error condition on socket for SYNC: Connection refused
568: S 06 Feb 2020 11: 36: 08.847 * Connecting to MASTER 10.0.2.15:6379
568: S 06 Feb 2020 11: 36: 08.848 * MASTER <-> REPLICA sync started
568: S 06 Feb 2020 11: 36: 08.849 # Error condition on socket for SYNC: Connection refused

On SLAVE :

127.0.0.1:6379> info replication
# Replication
role:slave
master_host:10.0.2.15
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:504
master_link_down_since_seconds:260
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:8881611bc86644a67455000652acd4faa348b0d7
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:504
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:504

On MASTER :

127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:0
master_replid:15da4be2b52cafbdab76d01c1cf29cfb80d352df
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

On the other hand when I do systemctl restart redis on the MASTER, the escalation resumes its place and this resyncronizes!

After MASTER reboot, and after systemctl restart redis on MASTER, here is SLAVE log file : (/var/log/redis/redis-server.log)

568:S 06 Feb 2020 11:37:12.380 * Connecting to MASTER 10.0.2.15:6379
568:S 06 Feb 2020 11:37:12.380 * MASTER <-> REPLICA sync started
568:S 06 Feb 2020 11:37:12.380 * Non blocking connect for SYNC fired the event.
568:S 06 Feb 2020 11:37:12.381 * Master replied to PING, replication can continue...
568:S 06 Feb 2020 11:37:12.383 * Trying a partial resynchronization (request 9a7c824b65e56d4ade069c0d1bb6ada5d38230c5:171).
568:S 06 Feb 2020 11:37:12.386 * Full resync from master: 22e902618007788885971bcd7e0ce165a0ab51f8:0
568:S 06 Feb 2020 11:37:12.386 * Discarding previously cached master state.
568:S 06 Feb 2020 11:37:12.438 * MASTER <-> REPLICA sync: receiving 288 bytes from master
568:S 06 Feb 2020 11:37:12.439 * MASTER <-> REPLICA sync: Flushing old data
568:S 06 Feb 2020 11:37:12.445 * MASTER <-> REPLICA sync: Loading DB in memory
568:S 06 Feb 2020 11:37:12.445 * MASTER <-> REPLICA sync: Finished with success
568:S 06 Feb 2020 11:37:12.446 * Background append only file rewriting started by pid 635
568:S 06 Feb 2020 11:37:12.485 * AOF rewrite child asks to stop sending diffs.
635:C 06 Feb 2020 11:37:12.486 * Parent agreed to stop sending diffs. Finalizing AOF...
635:C 06 Feb 2020 11:37:12.486 * Concatenating 0.00 MB of AOF diff received from parent.
635:C 06 Feb 2020 11:37:12.491 * SYNC append only file rewrite performed
635:C 06 Feb 2020 11:37:12.491 * AOF rewrite: 4 MB of memory used by copy-on-write
568:S 06 Feb 2020 11:37:12.582 * Background AOF rewrite terminated with success
568:S 06 Feb 2020 11:37:12.582 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
568:S 06 Feb 2020 11:37:12.582 * Background AOF rewrite finished successfully

If this is normal behavior for Redis, can I fix this problem?

Other Information :

root@redis-1:~# redis-cli -v
redis-cli 5.0.3

On Debian 10.2 Buster

After this problem I noticed that redis does not listen on 0.0.0.0 after a restart of the OS, on the other hand after having restarted redis, the served listens on 0.0.0.0 :

root@redis-1:~# netstat -plnt
Connexions Internet actives (seulement serveurs)
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name    
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      395/redis-server 12 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      394/sshd            
tcp6       0      0 :::22                   :::*                    LISTEN      394/sshd            
root@redis-1:~# systemctl restart redis
root@redis-1:~# netstat -plnt
Connexions Internet actives (seulement serveurs)
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name    
tcp        0      0 10.0.2.15:6379          0.0.0.0:*               LISTEN      443/redis-server 12 
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      443/redis-server 12 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      394/sshd            
tcp6       0      0 :::22                   :::*                    LISTEN      394/sshd

Comment From: marcraft2

FIXED! ==> My config on the MASTER: (/etc/redis/redis.conf)

maxmemory 4gb
maxmemory-policy allkeys-lru
supervised systemd
appendonly yes
bind 0.0.0.0

Now after Reboot MASTER :

root@redis-1:~# netstat -nlpt 
Connexions Internet actives (seulement serveurs)
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name    
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      395/redis-server 0. 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      394/sshd            
tcp6       0      0 :::22                   :::*                    LISTEN      394/sshd