ruby-on-rails - Rake 中止,无法连接到 postgresql : connection refused

标签 ruby-on-rails ruby git postgresql

我正在尝试使用 postgresql 在我全新的 Rails 项目上执行 rake 命令,但出现此错误:

rake aborted! 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?

Tasks: TOP => db:migrate (See full trace by running task with --trace)

real 0m3.245s user 0m1.668s sys 0m0.382s

这是我的第一个 Rails 应用程序,当我运行 rails server 时,这是输出:

=> Booting WEBrick

=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server [2012-06-19 01:17:30] INFO WEBrick 1.3.1 [2012-06-19 01:17:30] INFO ruby 1.9.3 (2012-04-20)

[x86_64-darwin11.3.0] [2012-06-19 01:17:30] INFO

WEBrick::HTTPServer#start: pid=4668 port=3000

Rails -v: Rails 3.2.3

gem 环境:

RubyGems Environment: - RUBYGEMS VERSION: 1.8.24 - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.3.0] - INSTALLATION DIRECTORY: /Users/kinhow/.rvm/gems/ruby-1.9.3-p194 - RUBY EXECUTABLE: /Users/kinhow/.rvm/rubies/ruby-1.9.3-p194/bin/ruby - EXECUTABLE DIRECTORY: /Users/kinhow/.rvm/gems/ruby-1.9.3-p194/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 - GEM PATHS: - /Users/kinhow/.rvm/gems/ruby-1.9.3-p194 - /Users/kinhow/.rvm/gems/ruby-1.9.3-p194@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/

如果有帮助:

运行 psql

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

最佳答案

首先,您需要确保 postgresql 正在运行。打开控制台并执行“ps auxw | grep post”并确保服务器正在运行。您应该至少有四个进程在运行,包括“postgres: writer process”。如果你不这样做,那么你还没有开始。即使您已启动它,您也必须将其配置为监听适当的端口(127.0.0.1 和“localhost”)。您是否编辑了 postgres.conf 文件和 pg_hba.conf 文件?如果你这样做了,你有没有重新启动服务器?您使用的是最新的 pg gem 吗?你如何启动你的服务器?

~查尔斯~

关于ruby-on-rails - Rake 中止,无法连接到 postgresql : connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11094321/

相关文章:

ruby-on-rails - 使用 whenever gem 安排顺序任务

ruby-on-rails - PubNub Rails 示例应用程序

ruby - Ruby 的 block 语法的起源是什么?

git - 将 git 标签从一个存储库复制到另一个存储库

ruby-on-rails - 如何进行ajax调用并显示错误消息

ruby - 类内的路由处理程序

ruby-on-rails - rails - 找不到生成器 rspec :install.

git - 第一次提交前撤消 'git reset --hard'

git - ssh 到两个独立的 gitlab 帐户

mysql - ActiveRecord 是否更改了我的序列化哈希上的编码