Error with wix-fetch

Hello, I am trying to make a rest call from Backend module to my app hosted at ’
http://localhost:8000/'. I keep getting the following error -

{
FetchError: request to http://localhost:8000/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
at ClientRequest. < anonymous > (/dynamic-modules/edm_root / cb294420 - e7bb - 11e8 - 82 f1 - f96f97dc1bc0 / node_modules / node - fetch / index.js: 133: 11)
at emitOne(events.js: 116: 13)
at ClientRequest.emit(events.js: 211: 7)
at Socket.socketErrorListener(_http_client.js: 387: 9)
at emitOne(events.js: 116: 13)
at Socket.emit(events.js: 211: 7)
at emitErrorNT(internal / streams / destroy.js: 64: 8)
at _combinedTickCallback(internal / process / next_tick.js: 138: 11)
at process._tickDomainCallback(internal / process / next_tick.js: 218: 9)
name: ‘FetchError’,
message: ‘request to http://localhost:8000/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000’,
type: ‘system’,
errno: ‘ECONNREFUSED’,
code: ‘ECONNREFUSED’,
errorGroup: ‘User’
}

My app is a simple django app with CORS enabled. I verified the endpoint works with POSTMAN. Any help will be appreciated.

HI Akul:

I think you might be confusing some networking concepts here.

It seems that you are testing something running on your laptop/desktop.
http://localhost:8000 is typically the loopback address on your computer. Normally only your computer knows what this means. So if you run postman on your computer it will find the address and resolve it. Wix is in the cloud running on a computer that doesn’t know about your desktop/laptop.

Being simplistic, if you ask Wix fetch to access something on http://localhost:8000 it will try to find something on the computer ‘in the cloud’ that Wix.com is running on and NOT your computer :-).

This is why we have web site addresses and an address look up system called DNS which helps computers find other computers. So if you haven’t given your computer a globally addressable web site name or use a globally accessible IP Address then Wix cannot find it.

Take a look at this youtube video for a better understanding of why what you are doing doesn’t work :wink:

Cheers
Steve

Hi Steve. Thanks for the reply. This is what sleep deprivation can do!! :wink: