sam local invoke fails on Ubuntu 20.04.1 (Windows 11 / WSL2 ) => error: Ports are not available

0

Hi,

I have problems invoking a lambda function locally.

I used the the Hello World example provided through sam init

I have

  • Ubuntu 20.04.1 (Windows 11 / WSL2 )
  • SAM CLI, version 1.80.0
  • Docker version 20.10.24, build 297e128

When executing

sam local invoke "HelloWorldFunction

I get:

Error: 500 Server Error: Internal Server Error ("b'Ports are not available: exposing port TCP 127.0.0.1:5301 -> 0.0.0.0:0: listen tcp 127.0.0.1:5301: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.'")

netstat shows no used port:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:35687         0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:41707         0.0.0.0:*               LISTEN
tcp6       0      0 :::8443                 :::*                    LISTEN
tcp6       0      0 :::3306                 :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
tcp6       0      0 :::7080                 :::*                    LISTEN
tcp6       0      0 :::8081                 :::*                    LISTEN
udp        0      0 127.0.0.1:323           0.0.0.0:*
udp6       0      0 ::1:323                 :::*
udp6       0      0 :::443                  :::*

What could resolve this issue?


complete output:

Invoking app.lambda_handler (python3.9)
Local image is up-to-date
Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.

Mounting /home/mustermann/lambda-functions/helloworld/sam-app/hello_world as /var/task:ro,delegated, inside runtime container

Error: 500 Server Error: Internal Server Error ("b'Ports are not available: exposing port TCP 127.0.0.1:5301 -> 0.0.0.0:0: listen tcp 127.0.0.1:5301: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.'")
Traceback:
  File "click/core.py", line 1055, in main
  File "click/core.py", line 1657, in invoke
  File "click/core.py", line 1657, in invoke
  File "click/core.py", line 1404, in invoke
  File "click/core.py", line 760, in invoke
  File "click/decorators.py", line 84, in new_func
  File "click/core.py", line 760, in invoke
  File "samcli/lib/telemetry/metric.py", line 184, in wrapped
  File "samcli/lib/telemetry/metric.py", line 149, in wrapped
  File "samcli/lib/utils/version_checker.py", line 42, in wrapped
  File "samcli/cli/main.py", line 92, in wrapper
  File "samcli/commands/local/invoke/cli.py", line 118, in cli
  File "samcli/commands/local/invoke/cli.py", line 203, in do_cli
  File "samcli/commands/local/lib/local_lambda.py", line 151, in invoke
  File "samcli/lib/telemetry/metric.py", line 324, in wrapped_func
  File "samcli/local/lambdafn/runtime.py", line 190, in invoke
  File "samcli/local/lambdafn/runtime.py", line 145, in run
  File "samcli/local/docker/manager.py", line 116, in run
  File "samcli/local/docker/container.py", line 316, in start
  File "docker/models/containers.py", line 400, in start
  File "docker/utils/decorators.py", line 19, in wrapped
  File "docker/api/container.py", line 1095, in start
  File "docker/api/client.py", line 263, in _raise_for_status
  File "docker/errors.py", line 31, in create_api_error_from_http_exception

An unexpected error was encountered while executing "sam local invoke".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20local%20invoke%20-%20APIError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20local%20invoke%20-%20APIError
gefragt vor einem Jahr71 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen