Jesus is Lord
Jesus is Lord

Reputation: 15399

Why am I getting this error? UnknownEndpoint: Inaccessible host: `devicefarm.us-east-1.amazonaws.com'

I'm trying to ListProjects in AWS Device Farm.

Here's my code:

const AWS = require('aws-sdk');

AWS.config.update({ region:'us-east-1' });
const credentials = new AWS.SharedIniFileCredentials({ profile: '***' });
AWS.config.credentials = credentials;
    
const devicefarm = new AWS.DeviceFarm();
    
async function run() {
  let projects = await devicefarm.listProjects().promise();
  console.log(projects);
}
    
run();

I'm getting this error:

UnknownEndpoint: Inaccessible host: devicefarm.us-east-1.amazonaws.com'. This service may not be available in the `us-east-1' region.

Upvotes: 8

Views: 34047

Answers (9)

Mohanish Shevde
Mohanish Shevde

Reputation: 1

If you are working locally, just try switching off the VPN.

Upvotes: -3

Ankit Shubham
Ankit Shubham

Reputation: 3599

For me, I had to switch off my VPN.

Upvotes: 0

Gilbert
Gilbert

Reputation: 3324

I just kept trying amplify init until it worked.

Upvotes: 0

vikasvmads
vikasvmads

Reputation: 552

I have the same problem. I just change the origin in the .env file.

Previous value:-

"Asia Pacific (Mumbai) ap-south-1"

Corrected value:-

"ap-south-1"

Upvotes: 1

Jarrett GXZ
Jarrett GXZ

Reputation: 608

Well for anyone still having this issue, I managed to solve it by changing the endpoint parameter passed in to the AWS.config.update() from an ARN string example arn:aws:dynamodb:ap-southeast-<generated from AWS>:table/<tableName> to the URL example https://dynamodb.aws-region.amazonaws.com, but replacing aws-region with your region in my case ap-southeast-1.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.NodeJs.Summary.html

Upvotes: 1

LeOn - Han Li
LeOn - Han Li

Reputation: 10194

I had the same issue and checked all the github issues as well as SO answers, not much help.

If you are also in the corporate environment as I am and get this error locally, it is quite possible because you did not have the proxy setup in the SDK.

import HttpsProxyAgent from 'https-proxy-agent';
import AWS from 'aws-sdk';

  const s3 = new AWS.S3({
    apiVersion: '2006-03-01',
    signatureVersion: 'v4',
    credentials,
    httpOptions: { agent: new HttpsProxyAgent(process.env.https_proxy) },
  });

Normally the code might work in your ec2/lambda as they have vpc endpoint but locally you might need proxy in order to access the bucket url: YourBucketName.s3.amazonaws.com

Upvotes: 3

KARTHIKEYAN.A
KARTHIKEYAN.A

Reputation: 20098

I got the same error, I have resolved following way

Error:

Region: 'Asia Pacific (Mumbai) ap-south-1' which I choose

Solution:

In region instead of writing the entire name, you should only mention the region code

Region: ap-south-1

Upvotes: 3

Nishant Ghodke
Nishant Ghodke

Reputation: 923

I faced the same issue and realised that uploads were failing because my internet connection was too slow to resolve the DNS of bucket URL. However, slow connection is not the only reason for this error -- network/server/service/region/data center outage could also be the possible root cause.

AWS provides a dashboard to get health reports of the services offered and the same is available at this link. API to access the services' health is also available.

Upvotes: 5

Jesus is Lord
Jesus is Lord

Reputation: 15399

According to http://docs.amazonaws.cn/en_us/general/latest/gr/rande.html, Device Farm is only available in us-west-2?

Changing AWS.config.update({ region:'us-east-1' }); to AWS.config.update({ region:'us-west-2' }); worked:

Working code:

const AWS = require('aws-sdk');
AWS.config.update({ region:'us-west-2' });
var credentials = new AWS.SharedIniFileCredentials({ profile: '***' });
AWS.config.credentials = credentials;

var devicefarm = new AWS.DeviceFarm();

async function run() {
    let projects = await devicefarm.listProjects().promise();
    console.log(projects);
}

run();

Upvotes: 7

Related Questions