serverless-localstack icon indicating copy to clipboard operation
serverless-localstack copied to clipboard

Inaccessible host: `localhost'. This service may not be available in the `us-east-1' region.

Open ravithejappl opened this issue 4 years ago • 10 comments

Can't I run this repo without aws account?

ravithejappl avatar Dec 28 '20 12:12 ravithejappl

Thanks for reporting @ravithejappl . Yes, you should be able to use the serverless-localstack plugin without an AWS account. Can you please share the details of your environment (operating system, Python/Docker version, etc.) and project setup (serverless.yml), to help us reproduce this issue? Thanks

whummer avatar Dec 28 '20 21:12 whummer

I am using macos catalina(10.15.5), docker engine 20.10.0, I am running this repo example only

I am getting below error Inaccessible host: localhost'. This service may not be available in the us-east-1' region. @whummer can you reply me as early as possible? We are dependent on it.

ravithejappl avatar Dec 30 '20 11:12 ravithejappl

i am also getting same error i am using nodejs,docker latest,and localstock latest version and error is "Inaccessible host: localhost'. This service may not be available in the us-east-1' region."

shreekant89 avatar Feb 26 '21 14:02 shreekant89

Same issue here:

Inaccessible host: 'localhost'. This service may not be available in the 'ap-southeast-1' region.

amouly avatar Mar 15 '21 06:03 amouly

Same here. I'm using amplifylocal init and getting this on an existing project

NimaSoroush avatar Mar 21 '21 10:03 NimaSoroush

Same issue here when trying to send messages to an SQS queue.

juanstiza avatar Aug 30 '21 14:08 juanstiza

if using docker check out this link

liam-ot avatar Sep 23 '21 13:09 liam-ot

Same here, started localstack start and sls deploy --stage local gives this:

Serverless: Recoverable error occurred (Inaccessible host: `localhost' at port `4566'. This service may not be available in the `us-west-1' region.), sleeping for ~7 seconds. Try 1 of 4

localstack says it's listen on 4566

Starting edge router (https port 4566)...
Ready.
[2021-11-22 19:48:34 +0000] [23] [INFO] Running on https://0.0.0.0:4566 (CTRL + C to quit)
2021-11-22T19:48:34.469:INFO:hypercorn.error: Running on https://0.0.0.0:4566 (CTRL + C to quit)

How is this supposed to work?

edbond avatar Nov 22 '21 19:11 edbond

Fixed by running docker to start localstack docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack

instead of localstack start

edbond avatar Nov 22 '21 20:11 edbond

I am getting the same issue when I try to invoke SQS queue from a lambda function. I tried the same step which @edbond mentioned above, but that didn't seems to be working.

local stack version: 0.14.1.3 docker engine: 20.10.13

In my lambda: new AWS.SQS({ endpoint: 'http://localhost:4566', region: 'us-east-1', });

Actually s3 is working by using below, but not sqs. new AWS.S3({ endpoint: 'http://localhost:4566', region: 'us-east-1', s3ForcePathStyle: true, });

Note: I am able to send sqs message from aws cli, but not from local stack lambda function.

elangoram1998 avatar Apr 06 '22 03:04 elangoram1998

This error still happening.

omerls-pw avatar Dec 28 '22 11:12 omerls-pw

I found that this error happen with serverless 2.x. If I upgrade the serverless to 3.x, this error will be resolved. But I still doubt why serverless-localstack plugin does not support serverless 2.x.

fisher-he avatar Jan 04 '23 07:01 fisher-he

I found that this error happen with serverless 2.x. If I upgrade the serverless to 3.x, this error will be resolved. But I still doubt why serverless-localstack plugin does not support serverless 2.x.

I'm using serverless 3.x

$ sls --version
Framework Core: 3.26.0
Plugin: 6.2.2
SDK: 4.3.2

omerls-pw avatar Jan 10 '23 08:01 omerls-pw

The default serverless host is using localhost, which on a mac is going to resolve to the IPv6 version instead of IPv4 127.0.0.1. Serverless is expecting the IPv4 address.

In your serverless config, override the host with host: 127.0.0.1 to force the resolution.

homeyer avatar Jan 12 '23 16:01 homeyer

I'm still experiencing the same issue using Serverless 3

Error:
Inaccessible host: `localhost' at port `4566'. This service may not be available in the `us-east-1' region.

With @homeyer solution I got:

Error: Hostname/IP does not match certificate's altnames: IP: 127.0.0.1 is not in the cert's list:

ze-ahmed avatar Jan 19 '23 21:01 ze-ahmed

I'm still experiencing the same issue using Serverless 3

Error:
Inaccessible host: `localhost' at port `4566'. This service may not be available in the `us-east-1' region.

With @homeyer solution I got:

Error: Hostname/IP does not match certificate's altnames: IP: 127.0.0.1 is not in the cert's list:

I was able to circumvent it with host: http://127.0.0.1 in the localstack custom config.

aron-airgraft avatar Jan 19 '23 21:01 aron-airgraft

@aron-airgraft tried it also and got the following error

Skipping template validation: Unsupported in Localstack

✖ Stack app-002-local failed to deploy (19s)
Environment: darwin, node 19.0.0, framework 3.26.0, plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
CREATE_FAILED: app-002-local (AWS::CloudFormation::Stack)
undefined

View the full error: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A000000000000%3Astack%2Fapp-002-local%2F4563fr1

ze-ahmed avatar Jan 19 '23 21:01 ze-ahmed

The default serverless host is using localhost, which on a mac is going to resolve to the IPv6 version instead of IPv4 127.0.0.1. Serverless is expecting the IPv4 address. In your serverless config, override the host with host: 127.0.0.1 to force the resolution.

Great catch, thanks for sharing the fix/workaround @homeyer !

Can you confirm if this entry in the config resolves the issue for you @ze-ahmed @aron-airgraft @omerls-pw @fisher-he @elangoram1998 @edbond @ravithejappl @amouly ?

custom:
  localstack:
    ...
    host: http://127.0.0.1

We'll look into getting this fix into the plugin itself, to make the switch between IPv4/IPv6 endpoints automatically. 👍

whummer avatar Jan 20 '23 12:01 whummer

Thanks a lot for your help. For me it worked with @homeyer solution + by adding HOSTNAME=127.0.0.1 in the localstack env profile

ze-ahmed avatar Jan 20 '23 13:01 ze-ahmed

Can you confirm if this entry in the config resolves the issue for you

Gets most of the way there but I ran into Hostname/IP does not match certificate's altnames: IP: 127.0.0.1 is not in the cert's list when using just host: 127.0.0.1, which I got around with host: http://127.0.0.1.

aron-airgraft avatar Jan 20 '23 15:01 aron-airgraft

Thanks for confirming @ze-ahmed @aron-airgraft . We have now pushed a few enhancements in version [email protected] - can you please give it another try with this version (and without using the custom host override). Thanks!

whummer avatar Jan 20 '23 17:01 whummer

@whummer thanks a lot, it works well for me I've removed the host property in serverless.yml and also the HOSTNAME=127.0.0.1 from the localstack env file

ze-ahmed avatar Jan 21 '23 06:01 ze-ahmed

@whummer - adding

custom:
  localstack:
    stages:
      - local
    host: http://127.0.0.1

fixed it.

🙏

omerls-pw avatar Jan 23 '23 10:01 omerls-pw

Thanks all for confirming - closing this issue as resolved, please let us know if the problem persists. Thanks

whummer avatar Jan 23 '23 12:01 whummer

@whummer the problem still requires workarounds for newer Nodejs versions because v17 changed a default behavior such that IPv6 is favored over IPv4. This breaks the defaults for LocalStack running on IPv4. See https://github.com/localstack/aws-cdk-local/issues/76#issuecomment-1412590519

Workarounds:

  • host: http://127.0.0.1 in serverless-localstack
  • export LOCALSTACK_HOSTNAME=127.0.0.1 in cdklocal

joe4dev avatar Feb 01 '23 19:02 joe4dev

Thanks for the update @joe4dev . 👍 Do you think we could somehow extend the check in getConnectHostname to also transparently resolve the issues with Node.js v17?

whummer avatar Feb 10 '23 10:02 whummer

@whummer yes, I fixed the Javascript bug in getConnectHostname and created PRs for:

  • serverless-localstack: https://github.com/localstack/serverless-localstack/pull/210
  • cdklocal: https://github.com/localstack/aws-cdk-local/pull/80

joe4dev avatar Feb 14 '23 17:02 joe4dev

This error exists in Macbook M2 sillicon ship machines

Kalanamith avatar Feb 16 '23 03:02 Kalanamith

@Kalanamith We just (2023-02-15T19:17:18.227Z) released serverless-localstack 1.0.4, which implements an IPv4 fallback to fix IPv6-related issues on macOS. Can you please check with the latest version?

joe4dev avatar Feb 16 '23 14:02 joe4dev

I'm also experiencing this problem on an M1 Max, and I'm using serverless-localstack version 1.0.4.

My package.json looks like this:

{
  "devDependencies": {
    "serverless": "^3.27.0",
    "serverless-localstack": "^1.0.4"
  },
  "resolutions": {
      "**/aws-sdk": "2.1313.0"
  }
}

serverless.yaml contains:

service: bref-test

provider:
  name: aws
  region: us-east-1
  runtime: provided.al2
  layers:
    - ${bref:layer.php-82}
  deploymentMethod: direct

plugins:
  - ./vendor/bref/bref
  - serverless-localstack

custom:
  localstack:
    stages:
      - local
    host: http://127.0.0.1
    debug: true

functions:
  hello:
    handler: index.php

I'm attempting to deploy with the following command:

AWS_PROFILE=localstack yarn serverless deploy --stage local

And this is the output I see:

[...]

Deploying bref-test to stage local (us-east-1)
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: dev
config.stage: local
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: dev
config.stage: local
Using custom endpoint for STS: http://127.0.0.1:4566
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566
Using custom endpoint for Lambda: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566
Skipping template validation: Unsupported in Localstack
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Overriding S3 templateUrl to http://127.0.0.1:4566
Using custom endpoint for CloudFormation: http://127.0.0.1:4566

✖ Stack bref-test-local failed to deploy (11s)
Environment: darwin, node 16.13.1, framework 3.27.0 (local), plugin 6.2.3, SDK 4.3.2
Credentials: Local, "localstack" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
UPDATE_FAILED: bref-test-local (AWS::CloudFormation::Stack)
undefined

View the full error: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A000000000000%3Astack%2Fbref-test-local%2Fa5ced7cf
error Command failed with exit code 1.

ramsey avatar Feb 25 '23 01:02 ramsey