RoR应用PostgreSQL连接超时故障求助:无法建立数据库连接
Rails应用PostgreSQL连接超时问题求助
此前我的Ruby on Rails(RoR)应用运行完全正常,但今日登录运行时出现如下错误:
ActiveRecord::ConnectionNotEstablished (connection to server at "3.109.111.41", port 5432 failed: Connection timed out (0x0000274C/10060) Is the server running on that host and accepting TCP/IP connections?):
已尝试的解决方案
- 在Services.msc中重启Postgres服务;
- 在database.yml中添加host、port并修改编码,修改后的配置如下:
development: <<: *default username: postgres password: qwerty encoding: UTF-8 host: localhost port: 5432
当前database.yml配置
default: &default adapter: postgresql encoding: unicode database: purchase_order pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 10 } %> development: <<: *default username: postgres password: my_db_pass
相关日志信息
Started GET "/" for ::1 at 2023-01-20 15:52:56 +0530 ActiveRecord::ConnectionNotEstablished (connection to server at "3.109.111.41", port 5432 failed: Connection timed out (0x0000274C/10060) Is the server running on that host and accepting TCP/IP connections? ): activerecord (6.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client' activerecord (6.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client' activerecord (6.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection' activerecord (6.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection' activerecord (6.1.7) lib/active_record/connection_handling.rb:327:in `retrieve_connection' activerecord (6.1.7) lib/active_record/connection_handling.rb:283:in `connection' activerecord (6.1.7) lib/active_record/migration.rb:611:in `connection' activerecord (6.1.7) lib/active_record/migration.rb:606:in `build_watcher' activerecord (6.1.7) lib/active_record/migration.rb:588:in `block in call' activerecord (6.1.7) lib/active_record/migration.rb:587:in `synchronize' activerecord (6.1.7) lib/active_record/migration.rb:587:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call' activesupport (6.1.7) lib/active_support/callbacks.rb:98:in `run_callbacks' actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call' web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app' web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call' web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch' web-console (4.2.0) lib/web_console/middleware.rb:17:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (6.1.7) lib/rails/rack/logger.rb:37:in `call_app' railties (6.1.7) lib/rails/rack/logger.rb:26:in `block in call' activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `block in tagged' activesupport (6.1.7) lib/active_support/tagged_logging.rb:37:in `tagged' activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `tagged' railties (6.1.7) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/request_id.rb:26:in `call' rack (2.2.4) lib/rack/method_override.rb:24:in `call' rack (2.2.4) lib/rack/runtime.rb:22:in `call' activesupport (6.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/static.rb:24:in `call' rack (2.2.4) lib/rack/sendfile.rb:110:in `call' actionpack (6.1.7) lib/action_dispatch/middleware/host_authorization.rb:148:in `call' webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request' rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call' railties (6.1.7) lib/rails/engine.rb:539:in `call' puma (5.6.5) lib/puma/configuration.rb:252:in `call' puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request' puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown' puma (5.6.5) lib/puma/request.rb:76:in `handle_request' puma (5.6.5) lib/puma/server.rb:443:in `process_client' puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
已为此问题困扰数小时,恳请各位提供技术帮助,非常感谢!
内容的提问来源于stack exchange,提问作者Diwanshu Tyagi
相关产品推荐
相关产品推荐

