2012-10-06 58 views
0

我試圖在全新的Mac上本地運行django項目。它一直在工作,直到昨天,我不知道發生了什麼,但突然間,我開始發現Redis錯誤。ConnectionError:錯誤2連接到Python中的unix套接字/ Django Redis

我可以加載不查詢數據庫的頁面,但一旦我嘗試做一個搜索,這在一定程度依賴於Redis的,這是行不通的。

任何想法?這是追溯。

Traceback (most recent call last): 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run 
    self.result = application(self.environ, self.start_response) 
    File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__ 
    return self.application(environ, start_response) 
    File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__ 
    response = self.get_response(request) 
    File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 179, in get_response 
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) 
    File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 111, in get_response 
    response = callback(request, *callback_args, **callback_kwargs) 
    File "/Users/dlitwak/mozio/dotcloud/demo/search/views.py", line 391, in results 
    cache.setDistanceAndDuration(distance, time, request.user.username) 
    File "/Users/dlitwak/mozio/dotcloud/demo/cache.py", line 305, in setDistanceAndDuration 
    self.cache.set(key, value, 1800) 
    File "/Library/Python/2.7/site-packages/redis_cache/cache.py", line 218, in set 
    result = self._set(key, pickle.dumps(value), int(timeout), client, _add_only) 
    File "/Library/Python/2.7/site-packages/redis_cache/cache.py", line 199, in _set 
    return client.setex(key, value, timeout) 
    File "/Library/Python/2.7/site-packages/redis/client.py", line 1221, in setex 
    return self.execute_command('SETEX', name, time, value) 
    File "/Library/Python/2.7/site-packages/redis/client.py", line 338, in execute_command 
    connection.send_command(*args) 
    File "/Library/Python/2.7/site-packages/redis/connection.py", line 287, in send_command 
    self.send_packed_command(self.pack_command(*args)) 
    File "/Library/Python/2.7/site-packages/redis/connection.py", line 269, in send_packed_command 
    self.connect() 
    File "/Library/Python/2.7/site-packages/redis/connection.py", line 217, in connect 
    raise ConnectionError(self._error_message(e)) 
ConnectionError: Error 2 connecting to unix socket: 127.0.0.1. No such file or directory. 

我們正在運行MYSQL。我可以通過終端訪問數據庫,所以我不認爲這是數據庫訪問問題。

回答

0

有時這是因爲Django無法連接到數據庫,並且redis正在拋出錯誤。 因爲你可以加載沒有分貝的頁面,似乎是這樣。

+0

不指定你是哪個數據庫使用,但如果它的postgres我建議你去與http://postgresapp.com/最簡單的方式來得到它和工作。 –

+0

我們肯定需要更多的信息來幫助你調試,你如何運行redis?和你的數據庫? –

+0

我們使用MYSQL。這不是數據庫問題,因爲我們有其他使用數據庫的頁面,它們正在檢索他們的信息。 – dlitwak

0

好的,所以我們終於搞定了。

由於某些原因,Redis不再自動啓動並且不在後臺運行。

我在Mac上工作,它以前在Ubuntu上運行時會自動執行此操作。解決方案是在單獨的終端窗口中運行「redis-server」。

我們仍在試圖找出如何使它自動啓動,或者爲什麼它首先停止,但耶。

0

如果您使用的是Mac,採用Homebrew包管理器可能是安裝和管理Redis的最好的方式。一旦安裝了Homebrew,只需在命令行上輸入brew install redis即可。

它的安裝後,你可以將它設置爲在啓動時自動運行:

ln -sfv /usr/local/opts/redis/*.plist ~/Library/LaunchAgents

那麼現在運行它:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist