![](/img/trans.png)
[英]Error: Connection refused - connect(2) for “localhost” port 25
[英]Seahorse::Client::NetworkingError: Connection refused - connect(2) for “localhost” port 8000
我正在构建一个Rails应用程序,并且使用dynamodb(使用dynamoid)作为数据库。 为了进行测试,我使用dynamodb-local。
从命令行进入测试数据库时,出现以下错误。
Seahorse :: Client :: NetworkingError:连接被拒绝-“ localhost”端口8000的connect(2)
config / initializers / dynamoid.rb
AWS_CONFIG = YAML.load_file("#{Rails.root}/config/aws.yml")[Rails.env]
Dynamoid.configure do |config|
config.adapter = 'aws_sdk_v2'
config.namespace = AWS_CONFIG['namespace']
config.warn_on_scan = false # Output a warning to the logger when you perform a scan rather than a query on a table.
config.read_capacity = 5 # Read capacity for tables, setting low
config.write_capacity = 5 # Write capacity for your tables
end
if Rails.env.test? || ENV['ASSET_PRECOMPILE'].present?
p "Comes here"
Aws.config[:ssl_verify_peer] = false
Aws.config.update({
credentials: Aws::Credentials.new('xxx','xxx'),
endpoint: 'https://localhost:8000',
region: 'us-west-2'
})
Rakefile:
task :start_test_dynamo do
FileUtils.cd('rails-root') do
sh "rake dynamodb:local:test:start"
sh "rake dynamodb:seed"
end
end
检查两件事
您的dynamodb-local
已加载?
您的端点正确吗?
将https://localhost:8000
更改为http://localhost:8000
(删除s
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.