首页 > 解决方案 > 如何连接到数字海洋服务器中的远程数据库

问题描述

我在 Windows 本地机器上有一个 rails 应用程序,我在数字海洋服务器 [ubuntu 服务器] 中有一个 postgresql 远程数据库。如何连接它,我试过这样:

数据库.yml

default: &default
adapter: postgresql
encoding: unicode
host: xxx.xxx.xxx.xx
username: username 
password: password
schema_search_path: "public,shared_extensions"

# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
 <<: *default
 database: database_name

当我重新启动服务器时出现错误 could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "xxx.xxx.xxx.xx" and accepting TCP/IP connections on port 5432?

我在做正确的程序吗?谁能帮我解决这个问题?

标签: ruby-on-railspostgresqldigital-ocean

解决方案


推荐阅读