- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试使用“$rails s”运行本地主机时,我不断收到此错误:
(Mac OSX 10.8.3)(ruby 2.0.0p195 (2013-05-14 修订版 40734) [x86_64-darwin12.3.0])( rails 3.2.11)(psql (PostgreSQL) 9.2.2 ) **用自制软件安装
我一直在卸载 postgresql 并重新安装,所以我有一种预感,某处可能存在冲突的库...我只是不知道从哪里开始。
我在同一个文件夹中有 Postgresql 9.1 和 9.2,只是将 9.1 移到了垃圾箱。
这是我在终端中运行“rails s”时的输出
Danny$ rails s
^[b=> Booting Thin
=> Rails 3.2.11 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': could not connect to server: Connection refused (PGError)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5433?
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /Users/Danny/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /Users/Danny/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:308:in `clear_cache!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418:in `_run__3642716200177086041__prepare__4186317719333288752__callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Danny/Dropbox/programming/coding/f_app/config/environment.rb:7:in `<top (required)>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:3:in `block in <main>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:in `new'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:in `<main>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
最佳答案
错误信息是有帮助的:
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?
您可能正在尝试连接到错误的端口。
标准端口是5432。检查你是如何(以及是否)启动你的 postgres 服务器的:
postgres@db:~$ ps -auxww | grep ^postgres
... <stripped more lines>
postgres 1274 0.0 0.3 1437240 57308 ? S May27 5:01 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
The manual has related information here.
在我的示例中,使用了来自 /etc/postgresql/9.1/main/postgresql.conf
的设置,它说(在许多其他设置中):
port = 5432
或者运行:
netstat -nlp | grep postgres
或者看看这里(至少在 Debian 或 Ubuntu 中):
ls -lA /var/run/postgresql/
如果您创建新的数据库集群,PostgreSQL 会选择下一个空闲端口。由于您重复安装,您可能混淆了端口号。
listen_addresses
或者你只是forgot to allow TCP/IP connections .相关回答:
关于ruby-on-rails - 连接被拒绝(PGError)(postgresql 和 rails),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16904997/
我有以下的named_scope,它在MySQL和sqlite中工作正常,但在Postgres中却很糟糕: course.rb named_scope :current, :conditions =>
在我的应用程序整夜闲置之后,当我在早上尝试访问它时,我收到 500 内部服务器错误并且日志显示“PGError:未连接到服务器”。在第一个请求之后,如果我再次刷新页面,一切都很好。 我在远程服务器上运
无法弄清楚这个 postgresql 错误到底在说什么。 PGError: ERROR: syntax error at or near "NULL" LINE 1: ...at` < '2011-
我在 Heroku 上而非本地收到 ActiveRecord PGError。来自 Heroku 日志的错误消息是: ActiveRecord::StatementInvalid (PGError:
我将 Rails 应用程序与 PostgreSql 数据库结合使用。我的应用程序在 PostgreSql 上运行良好。我想在服务器上运行我的迁移,我运行命令 RAILS_ENV=production
我在本地使用 SQLite 进行开发,但在我的生产主机上运行 PostgreSQL。在本地一切正常,但在生产主机上却不是这样。 我已经构建了一种搜索表单,通过它我可以使用我喜欢的任何组合来评估我数据库
当我尝试使用“$rails s”运行本地主机时,我不断收到此错误: (Mac OSX 10.8.3)(ruby 2.0.0p195 (2013-05-14 修订版 40734) [x86_64-dar
使用:Rails 3.0.3 和 Heroku 与 Postgresql。 我收到了很多异常,例如这个: A ActiveRecord::StatementInvalid occurred in ho
尝试在本地主机上启动我的 Rails 应用程序时出现以下错误: PGError (could not connect to server: No such file or directory Is t
我正在尝试将一个简单的应用程序推送到 heroku 并运行: heroku rake db:migrate 但是我得到以下错误: rake aborted! PGError: ERROR: rela
我正在使用 Ruby 1.9.2、Rails 3.1、Rspec、Postgres 和 Spork,但我无法让它们很好地协同工作。 第一次运行规范(Spork 在后台运行)工作正常。但是,当我第二次运
我有一个适用于 MySQL 但不适用于 PostGres 的 Ruby on Rails 条件 :conditions => ["A between ? and ? and B between ? a
我正在尝试将列“isGroup”的值更改为值“public”。 我创建了一个迁移: Post.connection.execute("update Posts set isgroup='public'
我最近完成了此处概述的数据库迁移过程: https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-p
我使用 heroku 和 postgresql 的应用程序 100% 宕机,应用程序崩溃并出现 H10 错误。我相信下面的日志是问题的根源: 2012-08-28T19:17:44+00:00 app
我为我的应用程序开发的这个页面在本地运行良好(使用 sqllite3),但是当我将它推送到使用 PostgreSQL 的 Heroku 时,我收到此错误: NeighborhoodsControlle
你好, 我在测试 Rails 应用程序时遇到此错误。我没有名为“说明”的表。但它显示了一个错误,如“错误:关系“指令”不存在”。总的来说,我在 64 次测试中遇到了与 64 次错误相同的错误。 我使用
当我尝试从 postgresql 数据库中的表中选择 cookie 值时,标题中出现错误,我不知道为什么。选择此表中的其他字段工作正常。 这是中断的行: user=UniqueUser.find(:a
情景: 我目前在 Heroku 上有一个应用程序,它是 Sinatra Application + ActiveRecord。目前有效: • 我可以查看我网站的静态页面 • 我能够运行迁移 • 我能够
我在从 Cloudmailin 接收 Rails 电子邮件时收到以下 PGError: PGError: ERROR: invalid byte sequence for encoding "UTF8
我是一名优秀的程序员,十分优秀!