saleor-platform icon indicating copy to clipboard operation
saleor-platform copied to clipboard

Apollo fails making connection to 127.0.0.1:8000 (Storefront fails to start)

Open gorjan-mishevski opened this issue 3 years ago • 4 comments

I just started the saleor platform without changing anything and was unable to run the storefront container. It seems Apollo is unable to connect to the graphql instance.

Opening the graphql editor works like a charm. ie: localhost:8000. The problem is when the storefront tries to connect to the graphql instance. Dashboard works, saleor core works. I am on version 3. Ran the command to update to the latest version for saleor platform.

Storefront is on commit: 4ff54d5598a85f49d9a2ec03196d874eb3f62e20

macOS big sur

I think this is a bug.

EDIT: Tried running on master branch, fails to start.

storefront_1  | { Error: Network error: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
storefront_1  |     at new ApolloError (/app/node_modules/apollo-client/bundle.umd.js:92:26)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:1588:34
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:2008:15
storefront_1  |     at Set.forEach (<anonymous>)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:2006:26
storefront_1  |     at Map.forEach (<anonymous>)
storefront_1  |     at QueryManager.broadcastQueries (/app/node_modules/apollo-client/bundle.umd.js:2004:20)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:1483:29
storefront_1  |     at process._tickCallback (internal/process/next_tick.js:68:7)
storefront_1  |   graphQLErrors: [],
storefront_1  |   networkError:
storefront_1  |    { FetchError: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
storefront_1  |        at ClientRequest.<anonymous> (/app/node_modules/node-fetch/lib/index.js:1461:11)
storefront_1  |        at ClientRequest.emit (events.js:198:13)
storefront_1  |        at Socket.socketErrorListener (_http_client.js:401:9)
storefront_1  |        at Socket.emit (events.js:198:13)
storefront_1  |        at emitErrorNT (internal/streams/destroy.js:91:8)
storefront_1  |        at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
storefront_1  |        at process._tickCallback (internal/process/next_tick.js:63:19)
storefront_1  |      message:
storefront_1  |       'request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000',
storefront_1  |      type: 'system',
storefront_1  |      errno: 'ECONNREFUSED',
storefront_1  |      code: 'ECONNREFUSED' },
storefront_1  |   message:
storefront_1  |    'Network error: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000',
storefront_1  |   extraInfo: undefined }
mailhog_1     | [APIv1] KEEPALIVE /api/v1/events
storefront_1  | (node:27) UnhandledPromiseRejectionWarning: Error: Network error: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
storefront_1  |     at new ApolloError (/app/node_modules/apollo-client/bundle.umd.js:92:26)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:1588:34
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:2008:15
storefront_1  |     at Set.forEach (<anonymous>)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:2006:26
storefront_1  |     at Map.forEach (<anonymous>)
storefront_1  |     at QueryManager.broadcastQueries (/app/node_modules/apollo-client/bundle.umd.js:2004:20)
storefront_1  |     at /app/node_modules/apollo-client/bundle.umd.js:1483:29
storefront_1  |     at process._tickCallback (internal/process/next_tick.js:68:7)
storefront_1  | (node:27) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 305)

gorjan-mishevski avatar Apr 27 '21 20:04 gorjan-mishevski

I am facing issue too with the frontend, it is not working for me too.

prashantidealittechno avatar May 04 '21 06:05 prashantidealittechno

Same thing happening here with latest master(saleor, dash & storefront) on Kubuntu 20.10

ApolloError: Network error: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
    at new ApolloError (/app/node_modules/apollo-client/bundle.umd.js:92:26)
    at /app/node_modules/apollo-client/bundle.umd.js:1588:34
    at /app/node_modules/apollo-client/bundle.umd.js:2008:15
    at Set.forEach (<anonymous>)
    at /app/node_modules/apollo-client/bundle.umd.js:2006:26
    at Map.forEach (<anonymous>)
    at QueryManager.broadcastQueries (/app/node_modules/apollo-client/bundle.umd.js:2004:20)
    at /app/node_modules/apollo-client/bundle.umd.js:1483:29
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  graphQLErrors: [],
  networkError: FetchError: request to http://localhost:8000/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8000
      at ClientRequest.<anonymous> (/app/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:315:20)
      at Socket.socketErrorListener (_http_client.js:469:9)
      at Socket.emit (events.js:315:20)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:80:21) {
    type: 'system',
    errno: 'ECONNREFUSED',
    code: 'ECONNREFUSED'
  },
  extraInfo: undefined
}

Looks like some commit on the storefront(probably https://github.com/mirumee/saleor-storefront/commit/ea54d72fd44644937f1cd9334d49e4241bb97a34 but cannot confirm) introduced server side fetching that trys to fectch from saleor API(http://localhost:8000/graphql/) from inside of the storefront container and fails due to saleor api running in different container.

Quick workaround is to set NEXT_PUBLIC_API_URI to your PCs ip address ie. 192.168.1.10

Deni-Iconis avatar May 11 '21 10:05 Deni-Iconis

Where are you configuring the NEXT_PUBLIC_API_URI value?

weeping-somnambulist avatar Jul 03 '21 02:07 weeping-somnambulist

Hi guys, im experiencing the same issue. Any updates on this one? Also tried to set the --hostname param to --host as i saw somewhere as a suggestion to fix this but it didnt do it for me.

kutucode avatar Sep 14 '21 23:09 kutucode

Hi, storefront has been rebuilt a lot, please try updating it

lkostrowski avatar Dec 12 '22 09:12 lkostrowski

Hello @lkostrowski updating it also fix the issue of saleor-platform? or is there another solution? I ran this with docker compose up. I dockerized this repository (saleor-platform) yesterday in a new VM. Error in the react-storefornt folder.

all containers are running:

image

this is the error output:

image

Thank you in advance!

AlexisHeap avatar Dec 14 '22 17:12 AlexisHeap

Hi @AlexisHeap , have you tried running fresh git clone first?

lkostrowski avatar Dec 15 '22 08:12 lkostrowski

Ok perfect, It's working now, thank you! @lkostrowski

AlexisHeap avatar Dec 15 '22 21:12 AlexisHeap

I tried to do git clone again and still the same error "ApolloError" Screen Shot 2022-12-28 at 4 35 40 PM

@lkostrowski

FouadDakhel96 avatar Dec 28 '22 13:12 FouadDakhel96

@saleor/storefront-checkout can you check this one?

lkostrowski avatar Jan 09 '23 09:01 lkostrowski

Storefront is no longer part of the platform, so I'm closing this. Please report related problems in the project's repository.

patrys avatar Mar 23 '23 19:03 patrys