大网数据广告活动
服务器运维问答

Redis cannot bind a specific ip address?

· 52CE 我爱测

I'm new to redis, but I want to set one up on my Raspberry Pi 4 (RP) for using it in a Django application (with celery). On my RP I have installed a firewall, ufw , and allowed incomming traffic from my PC's IP on port 6379 (redi…

问题原文

原帖链接 · CutePoison · CC BY-SA 4.0

I'm new to redis, but I want to set one up on my Raspberry Pi 4 (RP) for using it in a Django application (with celery).

On my RP I have installed a firewall, ufw, and allowed incomming traffic from my PC's IP on port 6379 (redis port).

I have then editted my redis.config on RP with

bind 192...... #The IP address for my pc

But now the redis-server wont start. The log writes:

Could not create server TCP listening socket 192....:6379 bind: Cannot assign requested address

If I bind 0.0.0.0 it works fine, and I can access the server from my local PC.

As far as I understand, the "bind" is like an "allow connections from this ip"but I might've misunderstood it.

Any ideas on what that error setting "means"? Is it a firewall issue? Do I miss something in my redis.config?.

社区高分解答

原帖链接 · vidarlo · CC BY-SA 4.0

As far as I understand, the "bind" is like an "allow connections from this ip"but I might've misunderstood it.

You have. The configuration file for redis is fairly self documenting:

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all available network interfaces on the host machine.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# Each address can be prefixed by "-", which means that redis will not fail to
# start if the address is not available. Being not available only refers to
# addresses that does not correspond to any network interface. Addresses that
# are already in use will always fail, and unsupported protocols will always BE
# silently skipped.

The bind directive tells redis which network interfaces to listen to, not which IP's you should accept connections from. 0.0.0.0 means all available network interfaces.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-09-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。