title: Redis wont start: Could not create server TCP listening socket 127.0.0.1:6379: bind: Address already in use
body: <p>I have installed <code>redis</code> in my AWS server. I have followed this: <a href="https://www.digitalocean.com/community/tutorials/how-to-install-secure-redis-centos-7" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-install-secure-redis-centos-7</a></p>
  <pre><code>$ systemctl start redis.service
  $ systemctl enable redis
    -&gt; Created symlink /etc/systemd/system/multi-user.target.wants/redis.service → /usr/lib/systemd/system/redis.service.
  $ systemctl status redis.service
  ● redis.service - Redis persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/redis.service.d
             └─limit.conf
     Active: failed (Result: exit-code) since Wed 2020-08-26 02:28:25 UTC; 10s ago
   Main PID: 5012 (code=exited, status=1/FAILURE)
  
  Aug 26 02:28:25 ip-xxx-xx-xx-xx.ap-southeast-2.compute.internal systemd[1]: Starting Redis persistent key-value database...
  Aug 26 02:28:25 ip-xxx-xx-xx-xx.ap-southeast-2.compute.internal systemd[1]: Started Redis persistent key-value database.
  Aug 26 02:28:25 ip-xxx-xx-xx-xx.ap-southeast-2.compute.internal systemd[1]: redis.service: Main process exited, code=exited, status=1/FAILURE
  Aug 26 02:28:25 ip-xxx-xx-xx-xx.ap-southeast-2.compute.internal systemd[1]: redis.service: Failed with result 'exit-code'.
  </code></pre>
  <p>And when I check the <code>/var/log/redis/redis.log</code> this is what I see:</p>
  <pre><code>5012:C 26 Aug 2020 02:28:25.574 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  5012:C 26 Aug 2020 02:28:25.574 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=5012, just started
  5012:C 26 Aug 2020 02:28:25.574 # Configuration loaded
  5012:C 26 Aug 2020 02:28:25.574 * supervised by systemd, will signal readiness
  5012:M 26 Aug 2020 02:28:25.575 # Could not create server TCP listening socket 127.0.0.1:6379: bind: Address already in use
  </code></pre>
  <p>And upon checking the ports:</p>
  <pre><code>$ netstat -tulpn
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      2812/redis-server *
  tcp6       0      0 :::6379                 :::*                    LISTEN      2812/redis-server *
  </code></pre>
  <p>This is showing the port <code>6379</code> is actually being used by <code>redis-server</code>.</p>
  <p>So why cannot it start then?</p>
  <p>Do I need to add any inbound/outbound rules in AWS? Please help.</p>
  <p><strong>UPDATE</strong></p>
  <p><code> ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd</code> command on terminal returns <code>bash: /etc/redis.conf: Permission denied</code>. Looks like need to give right permission to <code>/etc/redis.conf</code> file.</p>
  <pre><code>$ ls -l /etc/redis.conf
  -rw-r-----. 1 redis redis 62189 Aug 26 03:04 /etc/redis.conf
  </code></pre>
  <p>So what permission do I need to give here? Who should own this file?</p>