static-web-apps-cli: Could not connect to "http://localhost:4200". Is the server up and running?
Describe the bug My SWA project consists of
- Angular (v12) UI
- Integrated API (node v14)
About a month ago downloaded v 0.8.2, the following steps VSC created a local DEV I can F5 to launch swa emulator to run and debug both Angular and nodes backend:
- delete
.vscode
folder - click debug icon
- select
Show all automatic debug configuration
- select
Azure Static Web Apps ...
- select
angular-app: <name of angular app>
. - everything created.
- select
SWA: Run angular-app
from drop-down, F5 - after a little while, debugger bar changes to “Attach to Node Function”
- Terminal tells to use port
4280
, - a browser pops up itself, everything working like a charm!
After upgraded to v 0.8.3, F5 got
To Reproduce Repeating the same steps outlined above
- after select
Azure Static Web Apps ...
- no more
angular-app: <name of angular app>
Debug drop-down becomes
Uninstall v 0.8.3, reinstall v 0.8.2 would not get the same prompt back, and it keeps failing.
Desktop (please complete the following information): Version: 1.63.1 (system setup) Commit: fe719cd3e5825bf14e14182fddeb88ee8daf044f Date: 2021-12-14T02:13:54.292Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.19044
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 31 (13 by maintainers)
@TLKG @sa-schiefer apologies for the lack of communication. The fix hasn’t been merged or released in the Azure Static Web Apps extension yet.
We’ll track this issue in https://github.com/microsoft/vscode-azurestaticwebapps/issues/644
@alexweininger As discussed offline, here is a task configured to work
@AArkwellTB you are correct. I randomly ran into this issue twice. By switching to Node 16 with nvm, SWA seems to be running stably now.
I found a workaround by downgrading Node from 18 to 16, so it must be some conflict with new Node for my particular issue. A downgrade fixes all SWA local deployment issues.
If you are unable to connect to “http://localhost:4200/” and see an error message, it could mean that the server is not running or there is a configuration issue. Here are some steps you can take to troubleshoot the problem:
Check if the server is running:
Ensure that the server application (e.g., a development server like Angular’s, React’s, or another custom server) is running on your machine. Start the server if it is not already running. For example, if you are using Angular, run ng serve in the command prompt or terminal from your project’s root directory. If you are using React, run npm start or yarn start. Verify the port number:
Double-check that the server is set to run on port 4200, as specified in the URL. Some development servers might use different default ports or may have been configured to use a custom port. Check your project’s configuration files or the terminal output when starting the server to ensure the correct port is being used. Check firewall or security settings:
Your firewall or security software might be blocking the connection to port 4200. Check your firewall settings and make sure that the port is not blocked. You may need to create a rule or exception to allow traffic through port 4200. Restart the server:
Sometimes, the server may not start correctly, or it may be stuck in an unstable state. Try stopping the server (usually by pressing Ctrl+C in the terminal where it is running) and then starting it again.
Hi @AArkwellTB, the original issue was caused by strings not being escaped properly when sent to the shell. Is that the same issue you’re experiencing?
It would help us investigate if you opened a new issue and provided details and information about your specific environment there.
@sa-schiefer Awesome! We’re planning to release next week.
@alexweininger I can confirm that it works in this version. When will this be available publicly? Thank you!
How and where is it fixed? This issue was closed with no comment or reference and the problem still persists in the current versions.
Yeah, we have the fix ready for it.
CMD run
swa start http://localhost:4200 --run="npm start" --devserver-timeout=90000
: