2016-11-18 81 views
0

我的本地服務器不再適用於我的Rails應用程序。我收到以下錯誤消息:Rails本地服務器不運行:無法連接到服務器:連接被拒絕

could not connect to server: Connection refused 
    Is the server running on host "localhost" (127.0.0.1) and accepting 
    TCP/IP connections on port 5432? 
could not connect to server: Connection refused 
    Is the server running on host "localhost" (::1) and accepting 
    TCP/IP connections on port 5432? 

我去檢查我的數據庫日誌。這些都是過去的幾行:

STATEMENT: CREATE DATABASE starsetmetiers_development; 
ERROR: unrecognized configuration parameter "idle_in_transaction_session_timeout" 
STATEMENT: SET idle_in_transaction_session_timeout = 0; 

ERROR: unrecognized configuration parameter "row_security" 
STATEMENT: SET row_security = off; 

FATAL: database "stars_metiers_development" does not exist 
FATAL: database "stars_metiers_development" does not exist 
LOG: received smart shutdown request 
LOG: autovacuum launcher shutting down 
LOG: shutting down 
LOG: database system is shut down 

我最近摧毀了我的開發數據庫,​​並通過拉動生產一個重建一個。我認爲這是我的database.yml文件正確引用:

default: &default 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    # For details on connection pooling, see rails configuration guide 
    # http://guides.rubyonrails.org/configuring.html#database-pooling 
    pool: 5 

development: 
    <<: *default 
    database: starsetmetiers_development 

我不明白的地方這個錯誤來自(我沒有找到我的Postgres的文件夾也postmaster.pid文件)。 我該如何解決這個問題?

我收到此錯誤信息,當我嘗試運行rails c

/Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/irb/completion.rb:9:in `require': dlopen(/Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/x86_64-darwin14.5.0/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError) 
    Referenced from: /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/x86_64-darwin14.5.0/readline.bundle 
    Reason: image not found - /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/x86_64-darwin14.5.0/readline.bundle 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/irb/completion.rb:9:in `<top (required)>' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/console.rb:3:in `require' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/console.rb:3:in `<top (required)>' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:128:in `require' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:128:in `require_command!' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:59:in `console' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!' 
    from /Users/davidgeismar/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>' 
    from ./bin/rails:4:in `require' 
    from ./bin/rails:4:in `<main>' 
+0

它看起來就像您的posgres服務器要麼不在本地主機上一樣,要麼根本沒有運行。 –

+0

@SergioTulentsev你有什麼建議我應該做/檢查? –

回答

0

你錯過readline的依賴,因爲這條線在錯誤輸出顯示:

Library not loaded: /usr/local/opt/readline/lib/libreadline 

可以解決這個問題與

$ brew install readline 
0

參數idle_in_transaction_session_timeout是9中新增的.6 - 我認爲你正試圖將9.6備份上傳到早期版本的Postgres。

我注意到轉儲的頂部如下,並得到它的工作時,我有一個問題。當你有機會時你可能想更新Postgres。

SET statement_timeout = 0; 
SET lock_timeout = 0; 
-- SET idle_in_transaction_session_timeout = 0; 
SET client_encoding = 'UTF8'; 
SET standard_conforming_strings = on; 
SET check_function_bodies = false; 
SET client_min_messages = warning; 
-- SET row_security = off; 
0

無法連接到服務器:連接被拒絕 是運行在主機上的服務器的「本地主機」(127.0.0.1)和接收端口5432 TCP/IP連接?

上述錯誤的原因是您的postgresql服務器未運行。所以,請運行按您的操作系統如下:

Ubuntu的:須藤服務的PostgreSQL啓動
的Fedora:systemctl啓動PostgreSQL的
的Windows:NET START PostgreSQL相關9.xx

相關問題