Lambda runtime API endpoint AWS_LAMBDA_RUNTIME_API not defined


The Lambda service I’m working on has some custom Lambda integration code. Meaning that it typically makes HTTP calls to $AWS_LAMBDA_RUNTIME_API/2018-06-01/runtime/invocation/next in order to receive the next payload (usually an SQS message). And it uses the same endpoint but with a different path to send responses.

I see that unlike in the AWS Lambda runtime, in LocalStack the $AWS_LAMBDA_RUNTIME_API environment variable is not defined.

It took me quite a while looking at the LocalStack logs to figure out that the runtime API happens to live under

This isn’t explicitly exposed in any other environment variable. Well, the closest one is AWS_CONTAINER_CREDENTIALS_FULL_URI which happens to be

One could probably parse this to derive But is that a good idea…?

The way I managed to find port 9001 was by starting Localstack with LS_LOG=trace and then I found this log line:

[lambda c0aa831e132cdac34629e871ecc35643] time=“2024-01-31T13:42:01Z” level=debug msg=“Runtime API Server listening on” func=“*Server).Listen” file=“/home/runner/work/lambda-runtime-init/lambda-runtime-init/lambda/rapi/server.go:102”

Hence my attempt to use And indeed, everything works great. My lambda can read requests under

My question is, should this host name (well, localhost) and port be exposed in some environment variable? Probably under AWS_LAMBDA_RUNTIME_API if you want to allow other companies in a similar situation to have a seamless experience?

You probably already know this but this env var is defined by the AWS lambda runtime and it’s also documented on this AWS page.

Hope this helps anyone else that ran into this.


Hi @Andrej

Thank you for reaching out.

The environment variable $AWS_LAMBDA_RUNTIME_API should be available in LocalStack and is tested in test_introspection_invoke. Our parity test also shows that the following value is recorded here:


We also test a custom Lambda integration here using ${AWS_LAMBDA_RUNTIME_API} as follows:

EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next")

What LocalStack version are you using?
How does your code differ from the custom Lambda integration in our test suite?