ITmao
ITmao

Reputation: 61

Bind ip wrong in redis config

log:Creating Server TCP listening socket (myip:port): bind: Cannot assign requested address

my redis.conf

bind 10.114.234.11

when i cofig like this

bind 127.0.0.1

it works well

Upvotes: 6

Views: 14156

Answers (4)

Quân Hoàng
Quân Hoàng

Reputation: 411

At /etc/redis/redis.conf Please change

bind 127.0.0.1 ::1 

to

bind 0.0.0.0

then restart

/etc/init.d/redis-server restart

It's work to me

Upvotes: 4

Singaravelan
Singaravelan

Reputation: 67

I have faced the same issue when I changed the default redis.conf to custom Redis conf and after changing the bind as below then it started working, Please be aware that the below conf will open the Redis connection from all sources.

bind 127.0.0.1 -::1 to bind 0.0.0.0 -::1

Upvotes: 1

Satish Sojitra
Satish Sojitra

Reputation: 632

I also faced same issue while setting up redis for remote access. I was using google cloud platform and we created Google compute engine VM instance where we installed our Redis server. Redis doesn't ship with by default with security configured. You have to perform some steps to secure it. By updating IP address in redis.conf in bind will allow access only from that IP addresses. When we were doing it, we were getting same error.

To solve this issue we haven't added IP addresses in redis.conf file instead in Google cloud firewall rules when we add port open record in network -> IP ranges you can specify IP address which you want allow to access redis. In redis.conf file update from bind 127.0.0.1 to bind 0.0.0.0. So basically we will restrict it from Google cloud firewall rules dashboard.

Below are steps to add IP address restrictions:

  • Login to your google cloud console

  • Navigate to VPC Network -> Firewall Rules

  • Click on CREATE FIREWALL RULE or edit existing one if it's already there
  • In Source IP ranges add your IP address to allow access only - See below screenshot

enter image description here

  • Once you create this rule add this source tags under your VM instances network type and you are done.

Upvotes: 1

rchang
rchang

Reputation: 5236

You likely do not currently have any interfaces set up for the 10.x.x.x subnet. If you're on any flavor of Linux, ifconfig should be able to tell you which interfaces are currently set up. For example, I'm running Mint 17:

$ ifconfig | grep "inet addr"
inet addr:127.0.0.1  Mask:255.0.0.0
inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0

So I (like you) would not be able to bind Redis (or most any other service requesting a TCP socket) to 10.x.x.x. If you are really trying to listen for connections on that subnet, you will need to change your network setup (how exactly that would be done depends largely on your operating system).

Upvotes: 8

Related Questions