且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

救援:连接被拒绝 - 无法连接到 localhost:6379 上的 Redis

更新时间:2021-08-15 07:43:37

您是否验证过 redis-server 正在运行?请不要让我剖析以下命令,但您可以在终端中输入:

Have you verified redis-server is running? Please don't ask me to dissect the following command, but in a terminal you can type:

ps 辅助 |grep redis

然后您应该会看到如下内容:

You should then see something like:

redis 13319 0.0 0.0 2884 1056 ?ss 10:54 0:00/usr/bin/redis-server/etc/redis/redis.conf

如果它没有运行,我建议发出以下命令:

If it's not running, I recommend issuing the following command:

nohup redis-server &

这将启动一个 redis-server 进程并将其与终端分离.否则,我认为您需要在希望 redis-server 运行的整个时间内保持该终端打开.

That will start a redis-server process and detach it from the terminal. Otherwise I believe you need to leave that terminal open the entire time you want redis-server to be running.

(一旦你启动它,验证进程是否正在运行总是一个好主意,所以再次使用第一个命令.)

(Always a good idea to verify the process is running once you fire it up, so use that first command once more.)

更新:我不确定这是否适用于所有版本,但在 Ubuntu 16.04 上的 Redis Server 3.0.6 上,您也可以发出 sudo service redis-server status.您会收到一些详细的输出,因此我不会全部发布,但对于我们中的某些人来说,这可能是另一种选择.

Update: I'm not sure if this works for all versions, but on Redis Server 3.0.6 on Ubuntu 16.04, you can issue sudo service redis-server status as well. You'll receive some verbose output, so I'll not post it all, but that may be another option for some of us.