PG :: ConnectionBad,无法连接到服务器
问题描述:
我遇到了一个rails应用程序问题,我和其他几个人正在研究。我只是克隆了回购,并做要么轨分贝:迁移或试图达成一个页面(服务器运行时)导致此错误:PG :: ConnectionBad,无法连接到服务器
Started GET "/" for 127.0.0.1 at 2017-06-18 11:58:41 +0100
PG::ConnectionBad (could not connect to server: Cannot assign requested address (0x00002741/10049)
Is the server running on host "0.0.0.0" and accepting
TCP/IP connections on port 6543?
):
pg-0.19.0-x64 (mingw32) lib/pg.rb:45:in 'initialize'
pg-0.19.0-x64 (mingw32) lib/pg.rb:45:in 'new'
pg-0.19.0-x64 (mingw32) lib/pg.rb:45:in 'connect'
activerecord (5.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:701:in 'connect'
activerecord (5.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:220:in 'initialize'
activerecord (5.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:38:in 'new'
activerecord (5.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:38:in 'postgresql_connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in 'new_connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in 'checkout_new_connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in 'try_to_checkout_new_connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in 'acquire_connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in 'checkout'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in 'connection'
activerecord (5.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in 'retrieve_connection'
activerecord (5.1.1) lib/active_record/connection_handling.rb:116:in 'retrieve_connection'
activerecord (5.1.1) lib/active_record/connection_handling.rb:88:in 'connection'
activerecord (5.1.1) lib/active_record/migration.rb:562:in 'connection'
activerecord (5.1.1) lib/active_record/migration.rb:553:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/callbacks.rb:26:in 'block in call'
activesupport (5.1.1) lib/active_support/callbacks.rb:97:in 'run_callbacks'
actionpack (5.1.1) lib/action_dispatch/middleware/callbacks.rb:24:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/executor.rb:12:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:59:in 'call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in 'call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in 'block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in 'catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in 'call'
railties (5.1.1) lib/rails/rack/logger.rb:36:in 'call_app'
railties (5.1.1) lib/rails/rack/logger.rb:24:in 'block in call'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:69:in 'block in tagged'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:26:in 'tagged'
activesupport (5.1.1) lib/active_support/tagged_logging.rb:69:in 'tagged'
railties (5.1.1) lib/rails/rack/logger.rb:24:in 'call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/remote_ip.rb:79:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/request_id.rb:25:in 'call'
rack (2.0.3) lib/rack/method_override.rb:22:in 'call'
rack (2.0.3) lib/rack/runtime.rb:22:in 'call'
activesupport (5.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/executor.rb:12:in 'call'
actionpack (5.1.1) lib/action_dispatch/middleware/static.rb:125:in 'call'
rack (2.0.3) lib/rack/sendfile.rb:111:in 'call'
railties (5.1.1) lib/rails/engine.rb:522:in 'call'
puma (3.9.1) lib/puma/configuration.rb:224:in 'call'
puma (3.9.1) lib/puma/server.rb:602:in 'handle_request'
puma (3.9.1) lib/puma/server.rb:435:in 'process_client'
puma (3.9.1) lib/puma/server.rb:299:in 'block in run'
puma (3.9.1) lib/puma/thread_pool.rb:120:in 'call'
puma (3.9.1) lib/puma/thread_pool.rb:120:in 'block in spawn_thread'
我读过类似的问题,这都表示重新启动postgres,但在Windows上它有点混乱,所以我重新启动我的笔记本电脑,这并没有解决任何问题。我也试图重新克隆回购。请注意,其他rails项目也会工作,这让我想到这与database.yml有关,但我不知道该从哪里做些什么。 干杯
答
确保你的PostgreSQL服务正在运行,然后 请确保您有需要创建为您的应用程序数据库,你可以做rake db:create
也看到你的database.yml。默认的配置是这样的
development:
<<: *default
database: yourappname_development
那里,你还可以添加做出那样连接到你的Postgres所需要的信息,
port:
username:
password:
hostname:
您可以从另一运行轨道采取例如应用程式
+0
谢谢!解决了它:) – Dominus
我在Windows上,只需启动PGadmin并检查在迁移数据库后是否可以看到数据库。 (顺便说一句,你是否在你的电脑上安装了Postgres?) – Maxence
是PG在你的电脑上运行? :-) –