HalleyRios
HalleyRios

Reputation: 600

[fog][WARNING] Unable to fetch credentials: No route to host - connect(2) -(Errno::EHOSTUNREACH)

Hi I configured carrierwave with amazon s3 in ruby on rails. In the console show me this message

[fog][WARNING] Unable to fetch credentials: No route to host - connect(2) -(Errno::EHOSTUNREACH)

And my app is lag to load, but when i tried to upload a file the application hangs but the file is upload correct in the bucket.

this is my config s3. initializer.

CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'                        # required
  config.fog_credentials = {
    provider:              'AWS',                        # required
    aws_access_key_id:     'AK******',                        # required unless using use_iam_profile
    aws_secret_access_key: 'rKI********',                        # required unless using use_iam_profile
    use_iam_profile:       true,                         # optional, defaults to false
    region:                'us-east-2'                  # optional, defaults to 'us-east-1'

  }
  config.fog_directory  = '<name of bucked>'                                      # required
  config.fog_public     = false                                                 # optional, defaults to true
  config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" } # optional, defaults to {}
end

Upvotes: 3

Views: 1921

Answers (1)

equivalent8
equivalent8

Reputation: 14237

so the answer is in the comment: "set use_iam_profile to false" in the config/initializers/carrirewave.rb (or fog.rb) file for carrierwave/fog

CarrierWave.configure do |config|
  config.fog_credentials {
    provider:              'AWS', 
    aws_access_key_id:     'AK******',           
    aws_secret_access_key: 'rKI********', 
    use_iam_profile:       false,
    # ...

Why ??

use_iam_profile is pretty much different way of authenticating to s3 bucket. So if you use aws_access_key_id && aws_secret_access_key then use_iam_profile should be false

Upvotes: 2

Related Questions