question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web - VSCode launches on localhost:8080 by default, refused to connect

See original GitHub issue

Describe the bug It is concerning that the default Flutter app created in VSCode has a configuration that prevents a workable launch, following the official doc instructions. There is also no official documentation (and limited online community) coverage on this issue.

To Reproduce Steps to reproduce the behavior:

  1. Install VSCode and Flutter according to https://flutter.dev/docs/get-started/install/macos#web-setup
  2. Create a new Flutter app in VSCode
  3. Click Run > Run Without Debugging
  4. Chrome window opens with localhost:8080, page shows refused to connect error
  5. If I launch by terminal, or replace the default “pwa-chrome” config in launch.json by the following
        {
            "name": "Flutter for web",
            "type": "dart",
            "request": "launch",
            "program": "lib/main.dart",
            "args": [
              "-d",
              "chrome"
            ]
        }

then it launches as desired

Expected behavior

  1. Click Run > Run Without Debugging
  2. Chrome window launches with the app

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • VS Code version: 1.50.1
  • Dart extension version: 3.15.1
  • Dart/Flutter SDK version: 1.23.0-18.1.pre

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
DanTupcommented, Nov 2, 2020

Ah, I see. pwa-chrome is not related to this extension, and therefore we can’t control what it does. I suspect when you tried to run the project you didn’t have a Dart file open, so it should’ve shown this prompt:

Screenshot 2020-11-02 at 12 07 58

Here only the “Dart & Flutter” option will invoke our code. If you run the others, it will invoke their debuggers.

Let me know if you have any further issues/questions!

1reaction
WarmBreezeRisingcommented, Mar 30, 2022

@DanTup Thanks for your replies and explanations. It helped a lot for me and hope it helps others. I voted for the issue you opened. Any of the solutions would indeed make more sense and be less confusing (at least for beginners). Anyway, thanks a lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code debugger with Chrome refused to connect ...
I set up a brand new simple project with an index.html file to try to get Visual Studio code to launch it in...
Read more >
localhost refused to connect | VS code error for HTML - YouTube
Common error faced by the most beginner VS code user.This can be perfect solution for those who are looking to solve localhost error...
Read more >
Localhost Refused to Connect - How to Fix the Error
How to Solve the Localhost Refused to Connect Error? · Temporary Disable the Firewall · Check Localhost IP Address · Check Apache Server...
Read more >
Localhost Refused to Connect Error: 5 Confirmed Ways to Fix It
Localhost refused to connect error can be caused by an incorrectly configured port, insufficient permissions, or an inoperative web server.
Read more >
localhost refused to connect - Visual Studio Feedback
I launch VisualStudio 2017 Professional, I create a first new Project ... Added a binding for https on the default web server from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found