# Mopidy js connect ECONNREFUSED 127.0.0.1:80

**URL:** <https://discourse.mopidy.com/t/mopidy-js-connect-econnrefused-127-0-0-1-80/2109>\
**Category:** Misc\
**Created:** [December 15, 2017, 6:20pm UTC](https://discourse.mopidy.com/t/mopidy-js-connect-econnrefused-127-0-0-1-80/2109 "2017-12-15T18:20:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tudor2004](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/tudor2004/32/794_2.png) [@tudor2004](https://discourse.mopidy.com/u/tudor2004)\
**Post date:** [December 15, 2017, 6:20pm UTC](https://discourse.mopidy.com/t/mopidy-js-connect-econnrefused-127-0-0-1-80/2109/1 "2017-12-15T18:20:32Z")

</div>

I have created a small script that has the purpose to listen to mopidy events and redirect them to a localhost php (laravel) webserver than can handle the events. Maybe I’m getting the whole thing completely wrong…

This is the script I wrote:

```
const Mopidy = require('mopidy');
var mopidy = new Mopidy();

```

Now, whenever I do `npm start` and start my two line script I get a whole bunch of errors:

```
Mopidy.js is using the default calling convention. The default will change in the future. You should explicitly specify which calling convention you use.
WebSocket error: Event {
  type: 'error',
  message: 'Network error: ws://localhost/mopidy/ws: connect ECONNREFUSED 127.0.0.1:80',
  bubbles: false,
  cancelable: false,
  currentTarget:
   Client {
     url: 'ws://localhost/mopidy/ws',
     _driver:
      Client {
        version: 'hybi-13',
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        _request: null,
        _reader: [Object],
        _options: [Object],
        _maxLength: 67108863,
        _headers: [Object],
        __queue: [],
        readyState: -1,
        url: 'ws://localhost/mopidy/ws',
        io: [Object],
        messages: [Object],
        _extensions: [Object],
        _stage: 0,
        _masking: true,
        _protocols: [],
        _requireMasking: undefined,

```

And it gets much longer.

Can you tell me what am I doing here wrong? I am under the impression that I understood this entirely false.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [December 15, 2017, 7:09pm UTC](https://discourse.mopidy.com/t/mopidy-js-connect-econnrefused-127-0-0-1-80/2109/2 "2017-12-15T19:09:15Z")

</div>

From the docs at [Mopidy.js JavaScript library — Mopidy 3.4.2 documentation](https://docs.mopidy.com/en/latest/api/js/#creating-an-instance) :

> When you instantiate Mopidy() without arguments, it will connect to the WebSocket at /mopidy/ws/ on the current host. Thus, if you don’t host your web client using Mopidy’s web server, or if you use Mopidy.js from a Node.js environment, you’ll need to pass the URL to the WebSocket end point:

The error message states its trying to connect to mopidy at localhost/mopidy/ws. I would guess you don’t have a Mopidy server listening there on port 80. By default it’s at [http://localhost:6680/mopidy/ws](http://localhost:6680/mopidy/ws).
