-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot call API running on separate localhost port #260
Comments
This is due to the way Docker works. When accessing localhost (or 127.0.0.1) from within a Lambda function running in SAM Local, you're actually accessing the docker network, not your laptop/machine. Try using the main IP address for your local machine instead. If you're using Docker for Mac, you could also use the
source: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds |
If anyone runs into this while using Docker for Windows, try replacing localhost (or 127.0.0.1) with host.docker.internal |
This works for mac too. Thanks. |
For Linux use the IP address of the docker0 interface (172.17.0.1 by default). |
Thank you it works on my Ubuntu... but only for port 80, do you know the reason? |
work for me on mnajaroo for minio |
Use following commands in a terminal (choose one) to get that value: $ docker network inspect bridge -f "{{(index .IPAM.Config 0).Gateway}}"
$ ip address show docker0 | grep -Po 'inet \K[\d.]+' |
Not working for me. |
I am running another API service on port 3001. When I try to call it from my Lambda local function, I get an error:
2018-01-11T21:16:09.065Z f3abec54-3c7f-1f83-ea7e-691abaf23ed5 (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejectionid: 2): Error: connect ECONNREFUSED 127.0.0.1:3001
The part of the code in question (using the Axios library):
It works fine if I use a publicly available endpoint, the issue is only with localhost.
The text was updated successfully, but these errors were encountered: