Cheshie
Cheshie

Reputation: 2837

dart error - could not start pub serve or connect to pub

I'm trying to run this drag and drop API. When I try to run the dart file (with the dart editor) I get the following error:

could not start pub serve or connect to pub.

I'm not very familiar with dart. Where's my error?

Upvotes: 1

Views: 1347

Answers (2)

filiph
filiph

Reputation: 3103

Make sure you're trying to run the correct file. When running any file from the lib/ subdirectory, for example, pub will refuse to serve and — unfortunately — Dart Editor chooses to show the cryptic "could not start pub serve or connect to pub" message.

Click on the little black down arrow (▼) next to the green Run icon and make sure you're not running something other than you want.

enter image description here

(Dart Editor defaults to running the last Dart file you tried to run unless you specify otherwise.)

Upvotes: 1

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657018

Either you have another service listening on port 8080 (there is an open issue to make the port pub serve is using configurable) or there is already a pub serve instance running (I had this occassionally, that pub serve kept running after DartEditor crashed).

If it is the later, end DartEditor and check in the TaskManger (Windows) if any Dart process is still running and kill all if any, and then start DartEditor and try again.

Upvotes: 2

Related Questions