耙中止! PG::ConnectionBad:无法连接到服务器:连接被拒绝

rake aborted! PG::ConnectionBad: could not connect to server: Connection refused

我已经尝试安装 Consul 软件几个小时了。为此,我使用安装说明 https://docs.consulproject.org/docs/english-documentation/introduction/local_installation

不幸的是,我对 Ruby、Postgres 等几乎一无所知

不幸的是,当我运行执行以下命令时收到一条错误消息。

rake db: create
rake db: setup
rake db: dev_seed
rake db: test: prepare

这是整个问题:

rake db:create
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/definition.rb:31: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/decorator.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/sum.rb:43: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.2-compliant syntax, but you are running 2.7.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/type.rb:27: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/type/adapter_specific_registry.rb:9: warning: The called method `add_modifier' is defined here
/var/lib/gems/2.7.0/gems/acts-as-taggable-on-6.5.0/lib/acts_as_taggable_on/tagging.rb:9: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/associations.rb:1653: warning: The called method `belongs_to' is defined here
/var/lib/gems/2.7.0/gems/actionpack-5.2.4.4/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/actionpack-5.2.4.4/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here
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?
Couldn't create 'consul_development' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: 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?
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `initialize'
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `new'
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `connect'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:119:in `create'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.7.0/gems/airbrake-5.8.1/lib/airbrake/rake/task_ext.rb:19:in `execute'
/usr/share/rubygems-integration/all/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/exe/bundle:30:in `block in <top (required)>'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/exe/bundle:22:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)

有人知道如何解决这个问题吗?提前致谢!

这意味着 Postgresql 不是 运行,因此它无法创建数据库。

你安装了 Postgres 了吗?如果是这样,您可能可以使用以下方式启动服务:

sudo service postgresql restart

如果未安装 Postgres,您首先需要安装它。具体操作方法因您的系统而异:
https://www.postgresqltutorial.com/install-postgresql/