濮阳杆衣贸易有限公司

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

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

熱門標(biāo)簽:十堰營銷電銷機(jī)器人哪家便宜 超呼電話機(jī)器人 鄭州人工智能電銷機(jī)器人系統(tǒng) 北京400電話辦理收費(fèi)標(biāo)準(zhǔn) 山東外呼銷售系統(tǒng)招商 日本中國地圖標(biāo)注 宿遷便宜外呼系統(tǒng)平臺 魔獸2青云地圖標(biāo)注 貴州電銷卡外呼系統(tǒng)

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

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

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

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

要修改redis.windows.conf的配置文件(說明一下我的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

上面的代碼可以看到我的修改了哪些東西,之后再嘗試連接一下。

無法通過ip訪問redis服務(wù)

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

究其原因:

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

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

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

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

標(biāo)簽:臺州 北京 大慶 吉安 江蘇 楊凌 果洛 朝陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《redis不能訪問本機(jī)真實(shí)ip地址的解決方案》,本文關(guān)鍵詞  redis,不能,訪問,本機(jī),真實(shí),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《redis不能訪問本機(jī)真實(shí)ip地址的解決方案》相關(guān)的同類信息!
  • 本頁收集關(guān)于redis不能訪問本機(jī)真實(shí)ip地址的解決方案的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    莆田市| 泽库县| 霍州市| 临沭县| 那坡县| 岳池县| 江达县| 娄底市| 拉孜县| 泾川县| 密云县| 汉源县| 淳安县| 东丰县| 玉环县| 东乡| 凤山县| 庆城县| 天水市| 张掖市| 藁城市| 乌什县| 津市市| 河间市| 石门县| 临猗县| 沙坪坝区| 余江县| 绿春县| 容城县| 海安县| 岗巴县| 鲁山县| 化州市| 潞城市| 阿拉善右旗| 句容市| 青州市| 枝江市| 凤台县| 尉犁县|