0

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>'
4

3 に答える 3

1

パラメータ 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;
于 2016-11-22T17:33:24.313 に答える
0

サーバーに接続できませんでした: 接続が拒否されました サーバーはホスト "localhost" (127.0.0.1) で実行されており、ポート 5432 で TCP/IP 接続を受け入れていますか?

上記のエラーの原因は、postgresql サーバーが実行されていないことです。したがって、以下のように OS ごとに実行してください。

Ubuntu: sudo service postgresql start
Fedora: systemctl start postgresql
Windows: net start postgresql-9.xx

于 2016-11-22T17:50:18.257 に答える
0

エラー出力の次の行が示すように、readline 依存関係がありません。

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

これを修正するには

$ brew install readline
于 2016-11-18T20:33:48.530 に答える