简体   繁体   中英

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.

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();

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.

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

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

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

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"

I just kept trying amplify init until it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM