EC2内でredisを起動しています。
そこに同じEC2インスタンスにあるrailsからアクセスしようとすると、なぜか以下のエラーになります。
ruby
1Redis::CannotConnectError (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)):
redisの環境変数は以下の設定
ruby
1ENV["REDIS"] = "http://localhost:6379"
同じくEC2内のコマンドラインから以下のコマンドを叩くと、問題なくredisが起動しています。
redis-server
ruby
1➜ log git:(master) ✗ redis-server 2[5981] 07 Apr 23:24:56 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf' 3[5981] 07 Apr 23:24:56 * Server started, Redis version 2.4.10 4[5981] 07 Apr 23:24:56 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 5[5981] 07 Apr 23:24:56 * The server is now ready to accept connections on port 6379 6[5981] 07 Apr 23:24:56 - 0 clients connected (0 slaves), 717496 bytes in use 7[5981] 07 Apr 23:25:01 - 0 clients connected (0 slaves), 717496 bytes in use 8[5981] 07 Apr 23:25:06 - 0 clients connected (0 slaves), 717496 bytes in use
おそらく設定周りに問題あって接続出来ないのかと予測しているのですが、redisの環境変数以外に何か接続に問題でる設定はありますでしょうか??
【追記】
その後、以下のように環境変数を変更してみましたが、エラーのままです。
ruby
1ENV["REDIS"] = "localhost:6379"
ruby
1Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):
それとps -ef | grep redis
と叩いた結果は以下です。
ruby
1➜ log git:(master) ✗ ps -ef | grep redis 2myproject 6379 5618 0 23:51 pts/1 00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn redis
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。