Skip to content
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

swa does not recognize that the api is started when localhost resolves to ::1 #646

Open
1 of 2 tasks
tlaundal opened this issue Jan 24, 2023 · 2 comments
Open
1 of 2 tasks

Comments

@tlaundal
Copy link

tlaundal commented Jan 24, 2023

Are you accessing the CLI from the default port :4280 ?

  • No, I am using a different port number (--port) and accessing the CLI from that port
  • Yes, I am accessing the CLI from port :4280

Describe the bug

When starting my static web app, which has both static files and functions, swa get's stuck waiting for the api on http://localhost:7071 even when the azure function core tools have started the api. It seems this happens because localhost resolves to ::1 (The IPv6 loopback address) on my system, while the api is started on 127.0.0.1 (IPv4 loopback address).

My workaround is to specify the host property in swa-cli.config.json or the --host flag to be 127.0.0.1.

To Reproduce
Steps to reproduce the behavior:

  1. Be on a system where localhost resolves to ::1. The most consistent test for this in this case is to see which IP address wait-on resolves (swa uses wait-on) by running npx wait-on -v tcp:localhost:7071
  2. Have a SWA app with both static files and functions. Configure swa-cli.config.json with outputLocation and apiLocation as needed, but without host or similar.
  3. Execute command swa start
  4. After a while, you will get the message
[swa] ✖ Waiting for http://localhost:7071 to be ready
[swa] ✖ Could not connect to "http://localhost:7071". Is the server up and running?

Expected behavior
swa should successfully start up. In particular the message below is expected.

[swa] ✔ Connected to http://127.0.0.1:7071 successfully

Desktop (please complete the following information):

  • OS: Fedora Linux 37 Workstation Edition
  • uname -a: Linux xps13 6.1.5-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 12 15:52:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
tlaundal added a commit to tlaundal/svelte-adapter-azure-swa that referenced this issue Jan 24, 2023
The host option is needed for `swa` to work on systems where `localhost` resolves to the IPv6 loopback address `::1`.  See Azure/static-web-apps-cli#646.
tlaundal added a commit to tlaundal/svelte-adapter-azure-swa that referenced this issue Jan 24, 2023
The host option is needed for `swa` to work on systems where `localhost` resolves to the IPv6 loopback address `::1`.  See Azure/static-web-apps-cli#646.
@rupareddy5-21
Copy link
Contributor

Please feel free to track the original issue #663

@penfold
Copy link

penfold commented Jun 26, 2023

We see a similar-looking issue in Windows where localhost resolves to IPv6 loopback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants