佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > redis不能訪問(wèn)本機(jī)真實(shí)ip地址的解決方案

redis不能訪問(wèn)本機(jī)真實(shí)ip地址的解決方案

熱門(mén)標(biāo)簽:網(wǎng)站排名優(yōu)化 百度競(jìng)價(jià)排名 呼叫中心市場(chǎng)需求 鐵路電話系統(tǒng) AI電銷(xiāo) 服務(wù)外包 地方門(mén)戶(hù)網(wǎng)站 Linux服務(wù)器

redis無(wú)法訪問(wèn)本機(jī)真實(shí)ip地址

1.我在進(jìn)行用jedis來(lái)連接redis時(shí)出現(xiàn)了問(wèn)題:

我用Jedis jedis = new Jedis("127.0.0.1",6379);可以成功連接,但是我如果把127.0.0.1換成的本機(jī)地址如192.168.1.103發(fā)現(xiàn)會(huì)報(bào)錯(cuò).

2.解決這個(gè)問(wèn)題

要修改redis.windows.conf的配置文件(說(shuō)明一下我的redis是在windows版的)

這里要改兩個(gè)地方:

  • 1.修改bind的ip
  • 2.修改protected-mode yes為protected-mode no

我的修改如下

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.1.103

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode no

上面的代碼可以看到我的修改了哪些東西,之后再?lài)L試連接一下。

無(wú)法通過(guò)ip訪問(wèn)redis服務(wù)

嘗試在本機(jī)以及其他主機(jī)通過(guò)ip來(lái)訪問(wèn)redis服務(wù)時(shí),一直出現(xiàn)錯(cuò)誤,無(wú)法通過(guò)IP訪問(wèn)redis服務(wù)。

究其原因:

redis.conf文件中配置了訪問(wèn)限制,通過(guò)bind來(lái)限制了ip訪問(wèn),默認(rèn)為127.0.0.1

注釋掉bind之后,本地可以通過(guò)ip訪問(wèn),但是其他主機(jī)無(wú)法訪問(wèn),在redis3之后,有一個(gè)protected-mode 參數(shù),默認(rèn)開(kāi)啟 yes,改成no,重啟服務(wù)即可。

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • Redis IP地址的綁定的實(shí)現(xiàn)
  • 解決webpack無(wú)法通過(guò)IP地址訪問(wèn)localhost的問(wèn)題
  • 詳解java 客戶(hù)端鏈接不上redis解決方案

標(biāo)簽:衡水 黃山 崇左 湘潭 仙桃 銅川 蘭州 湖南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《redis不能訪問(wèn)本機(jī)真實(shí)ip地址的解決方案》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢(xún)

    • 400-1100-266
    都兰县| 东辽县| 报价| 扎赉特旗| 靖远县| 新营市| 台中市| 库伦旗| 平武县| 苍南县| 靖州| 东源县| 金秀| 巴南区| 长春市| 永州市| 阜康市| 泰来县| 旺苍县| 达尔| 库尔勒市| 潍坊市| 邓州市| 临武县| 大方县| 富源县| 北京市| 疏附县| 丰宁| 布拖县| 登封市| 万州区| 会昌县| 萝北县| 嫩江县| 吉木乃县| 西和县| 昭觉县| 郑州市| 陕西省| 平阳县|