当前位置:网站首页>Could not connect to redis at 192.168.164.118:6379: connection rejected under Linux
Could not connect to redis at 192.168.164.118:6379: connection rejected under Linux
2022-07-16 08:29:00 【kjshuan】
In virtual machine version Centos7 Connect in the environment redis
[[email protected] ~]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>
But use IP Connection error , The tips are as follows :
[[email protected] ~]# redis-cli -h 192.168.133.136 -p 6379
Could not connect to Redis at 192.168.133.136:6379: Connection refused
Could not connect to Redis at 192.168.133.136:6379: Connection refused
not connected
Check the configuration file and find :
function Redis It is dangerous for computers to be directly exposed to binding to all interfaces , It will expose the instance of everyone on the Internet .
follow bind Instructions , This will force Redis Monitor only IPv4 Fallback interface address ( It means Redis Will be able to accept only connections from the same computer ).
terms of settlement :
1、 stay redis The configuration file /etc/redis.conf Add local to IP Addressbind 127.0.0.1 192.168.133.136
1
2、 Comment out redis The configuration file /etc/redis.conf in bind Instructions# bind 127.0.0.1
Connect redis
[[email protected] ~]# redis-cli -h 192.168.133.136 -p 6379
192.168.133.136:6379>
Set up redis The remote access
First , You want to configure redis The remote access , It needs to be clear redis.conf The concept and function of the three configuration items in the configuration file :
bind The function of configuration : Used to specify the corresponding to the local network card that is allowed to access IP Address .
among 192.168.18.8 yes ens33 network address ,127.0.0.1 yes lo Return address .redis.conf The default is bind 127.0.0.1, Default redis Only local access is allowed .
protected-mode Pattern meaning : A security layer , The purpose is to prevent redis Random access by the Internet . If protected-mode Mode on , When not bind given IP Address , And the access password is not set , Only local lo Return address 、unix Host name access .
requirepass: Access password . After setting , Connect redis You must use this password , Otherwise, you cannot set and view data .
Combined with the above three configuration items , We can implement the following schemes redis External access :
1、 Not set up bind Parameters ( Comment out all bind That's ok ), close protected-mode Pattern , Do not set access password .
2、 Not set up bind Parameters ( Comment out all bind That's ok ), close protected-mode Pattern , Set access password .
3、 Not set up bind Parameters , Turn on protected-mode Pattern , Set access password .
4、 Set up bind Parameters , Turn on protected-mode Pattern , Do not set access password
5、 Set up bind Parameters , Turn on protected-mode Pattern , Set access password
reason : The server is not started ........
Violence solutions
# Get into redis The configuration directory
cd /opt/soft/redis6379/
# Start the server manually
redis-server

# Open another window to run directly
redis-cli -h 192.168.64.138 -p 6379
Option two
# This machine ip Or change it to where the application service is located ip
bind 127.0.0.1
# The protection mode can be turned off by default
protected-mode no
#redis password
requirepass redispwd

Successful connection !!!
边栏推荐
- 一个XML文件例子
- Kubernetes Dashboard
- 【每日一题】二叉搜索树与双向链表
- The mental journey of a sealer maintainer
- Wechat enterprise small program graduation project (6) opening defense ppt
- 测试基础2
- 一个简单的表单例子
- STM32实现NRF24L01通信
- Understanding the application on MySQL
- Wechat classroom appointment of applet completion works applet graduation project (4) opening report
猜你喜欢
![[daily question 1] find the nearest common ancestor of two nodes in the binary tree](/img/b1/0c035f8482da39bebb51bab4709e4c.png)
[daily question 1] find the nearest common ancestor of two nodes in the binary tree

斐波那契堆 - 解析与实现

测试基础1

What is fastmixer cash virtual currency encryption mixer?

Small program graduation design of wechat enterprise company (2) small program function

(3.1)【木马-合成技术】

一、mysql的安装部署

The source code is compiled according to mongoc

London Metal real-time market and operation skills

Glue terraform ecology to kubernetes world
随机推荐
shell脚本学习记录
Send your code into space and develop "the greatest work" together
HJ3 明明的随机数 HJ03
CentOS系统安装MySQL数据库
CVPR | self enhanced unpaired image defogging based on density and depth decomposition
Golang handles web post, get request and string to JSON format conversion
Wechat enterprise small program graduation project (6) opening defense ppt
Test basis 1
解决GD32F20X支持包安装后打开官方例程无法识别芯片问题
malloc,vmalloc与kmalloc,free,kfree与vfree的区别和联系
London Metal real-time market and operation skills
Spot gold knowledge that Xiaobai must learn (24 terms)
Panorama of kubernetes troubleshooting
【每日一题】判断是不是完全二叉树
猫狗分類-VGG16-bottleneck
C restated value type
VRRP基础配置
Object中线程相关方法wait、notify、notifyAll分析
[Unity] 初探
Use of backup cache API