Having trouble finding host to connect to redis (via redis gem)

282 views
Skip to first unread message

dukha

unread,
Oct 23, 2011, 2:28:31 AM10/23/11
to redi...@googlegroups.com
Hi
I'm running redis on my development machine using redis gem.

I've just switched from suse to ubuntu and am having trouble getting redis to work the same as on suse.

In a terminal
$>hostname gives highfield-45
however
in ruby console
irb> r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host =>'highfield-45')
gives Errno::ECONNREFUSED: Connection refused - Unable to connect to Redis on highfield-45:6379

irb>  r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host =>'localhost')
gives a valid connection

$> hostname -i gives 127.0.1.1
but
irb>r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host =>'127.0.1.1')
gives Errno::ECONNREFUSED: Connection refused - Unable to connect to Redis on 127.0.1.1:6379

All 3 of these worked on suse (with a different hostname/ip of course)

Has any one an idea what is going on here?

Sergei Tulentsev

unread,
Oct 23, 2011, 2:45:25 AM10/23/11
to redi...@googlegroups.com
try 127.0.0.1
Also, what is redis set up to bind to? This is excerpt from my config file. In this case, it will listen only on 10.0.0.1

# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
# bind 127.0.0.1
bind 10.0.0.1


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/Rpdra1rmd3QJ.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.



--
Best regards,
Sergei Tulentsev

Chris Johnson

unread,
Oct 23, 2011, 2:35:39 AM10/23/11
to redi...@googlegroups.com
I am new to Redis and trying to get learn the basics. Due to the fork process, I am having to run the 0.5 train and am running into an error with the redis module. When I run the simple.js example script I get the following error:

The 'sys' module is now called 'util.'

Also, the client is not closing with the client.quit() statement.

When I run the script with 0.4 train, everything works as expected.

I have tried researching the issue and found documentation around the change from the 0.2 to 0.3 train, but nothing relating to the 0.5 train. I am not so much concerned with the module issue as the client not closing out cleanly. Any help is greatly appreciated.

Thanks
Chris

dukha

unread,
Oct 25, 2011, 12:41:47 AM10/25/11
to Redis DB
Hey Sergei
Many thanks. Putting in the actual ip in the bind worked fine when
specifying either the ip or the hostname in connection statement.

I still don't understand what the bind is for and what I have to do to
make redis accessible while running on another server from the main
application. I would have thought the hostname (and port) would be
enough but apparently only enough if redis is bound to the correct ip.
Seems like redundancy to me.

Is there a security risk in commenting out the bind statement in
redis.conf?

Kind regards

Mark

On Oct 23, 4:45 pm, Sergei Tulentsev <sergei.tulent...@gmail.com>
wrote:
> try 127.0.0.1
> Also, what is redis set up to bind to? This is excerpt from my config file.
> In this case, it will listen only on 10.0.0.1
>
> # If you want you can bind a single interface, if the bind option is not
> # specified all the interfaces will listen for incoming connections.
> #
> # bind 127.0.0.1
> bind 10.0.0.1
>
>
>
>
>
>
>
>
>
> On Sun, Oct 23, 2011 at 10:28 AM, dukha <mplen...@gmail.com> wrote:
> > Hi
> > I'm running redis on my development machine using redis gem.
>
> > I've just switched from suse to ubuntu and am having trouble getting redis
> > to work the same as on suse.
>
> > In a terminal
> > $>*hostname *gives highfield-45
> > however
> > in ruby console
> > irb> *r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host
> > =>'highfield-45')*
> > gives Errno::ECONNREFUSED: Connection refused - Unable to connect to Redis
> > on highfield-45:6379
>
> > irb>  *r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host
> > =>'localhost')*
> > gives a valid connection
>
> > $> *hostname -i *gives 127.0.1.1
> > but
> > irb>*r = Redis.new(:password=>'abcdef', :db=>0, :port => 6379, :host
> > =>'127.0.1.1')*

Sergei Tulentsev

unread,
Oct 25, 2011, 4:25:05 AM10/25/11
to redi...@googlegroups.com
Yes, there might be a security risk. For example, my machine has two network cards. One is for the internet and has IP 188.93.x.x and another is intranet (10.0.0.1). By binding redis to the latter, I eliminate the risk that someone from the internet will connect to my redis.
You can achieve this also by tuning your firewall :-)

Another example is when redis is running on the same machine as its client. In this case, you want to bind it to localhost only, so that no external connections are accepted.

Matthew Ranney

unread,
Nov 21, 2011, 9:51:32 PM11/21/11
to redi...@googlegroups.com
Sorry, I'm just getting through a big email backlog.

I've published an update to node_redis that addresses these and other issues with 0.6.  Please report any issues with node_redis on the github issue tracker:


Thanks.

Reply all
Reply to author
Forward
0 new messages