serverless-localstack
serverless-localstack copied to clipboard
Inaccessible host: `localhost'. This service may not be available in the `us-east-1' region.
Can't I run this repo without aws account?
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
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.
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."
Same issue here:
Inaccessible host: 'localhost'. This service may not be available in the 'ap-southeast-1' region.
Same here. I'm using amplifylocal init
and getting this on an existing project
Same issue here when trying to send messages to an SQS queue.
if using docker check out this link
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?
Fixed by running docker to start localstack
docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack
instead of localstack start
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.
This error still happening.
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 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 whyserverless-localstack
plugin does not supportserverless
2.x.
I'm using serverless 3.x
$ sls --version
Framework Core: 3.26.0
Plugin: 6.2.2
SDK: 4.3.2
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.
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'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 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
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. 👍
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
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
.
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 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
@whummer - adding
custom:
localstack:
stages:
- local
host: http://127.0.0.1
fixed it.
🙏
Thanks all for confirming - closing this issue as resolved, please let us know if the problem persists. Thanks
@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
incdklocal
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 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
This error exists in Macbook M2 sillicon ship machines
@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?
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.