Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind ip wrong in redis config

Tags:

redis

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

like image 359
ITmao Avatar asked Mar 18 '23 13:03

ITmao


2 Answers

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).

like image 180
rchang Avatar answered Apr 27 '23 21:04

rchang


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.
like image 34
Satish Sojitra Avatar answered Apr 27 '23 22:04

Satish Sojitra