[solved] Parse server self-host (Bad Gateway)

Hi,

I am following self-hosted moralis server tutorial (https://www.youtube.com/watch?v=l2qTyc-V9cM&ab_channel=MoralisWeb3) and having Bad Gateway 502 error when try to run the application (yarn dev).

Currently i am in windows 10 and using repo: https://github.com/noviulian/parse-server-migration and my env setup looks like below:

May i know this is moralis API issue or my setup issue?

Thanks in advance

This is the long error code:

        errored: HTTPError: Response code 502 (Bad Gateway)
            at Request.<anonymous> (D:\Develop\MetaProject\parse-server-migration-main\node_modules\got\dist\source\as-promise\index.js:118:42)
            at processTicksAndRejections (node:internal/process/task_queues:96:5) {
          code: 'ERR_NON_2XX_3XX_RESPONSE',
          timings: {
            start: 1684481257959,
            socket: 1684481257960,
            lookup: 1684481257961,
            connect: 1684481257961,
            secureConnect: undefined,
            upload: 1684481257961,
            response: 1684481258068,
            end: 1684481258068,
            error: undefined,
            abort: undefined,
            phases: [Object]
          }
        },
        closed: true,
        closeEmitted: true,
        [Symbol(kOnFinished)]: []
      },
      allowHalfOpen: true,
      requestInitialized: true,
      redirects: [],
      retryCount: 0,
      _progressCallbacks: [],
      write: [Function: onLockedWrite],
      end: [Function: onLockedWrite],
      options: {
        method: 'POST',
        retry: {
          calculateDelay: [Function: calculateDelay],
          limit: 0,
          methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
          statusCodes: [
            408, 413, 429, 500,
            502, 503, 504, 521,
            522, 524
          ],
          errorCodes: [
            'ETIMEDOUT',
            'ECONNRESET',
            'EADDRINUSE',
            'ECONNREFUSED',
            'EPIPE',
            'ENOTFOUND',
            'ENETUNREACH',
            'EAI_AGAIN'
          ],
          maxRetryAfter: Infinity
        },
        headers: {
          'user-agent': 'got (https://github.com/sindresorhus/got)',
          'content-type': 'application/json',
          accept: 'application/json',
          'content-length': '74',
          'accept-encoding': 'gzip, deflate, br'
        },
        hooks: {
          init: [],
          beforeRequest: [],
          beforeRedirect: [],
          beforeRetry: [],
          beforeError: [],
          afterResponse: []
        },
        cache: undefined,
        dnsCache: undefined,
        decompress: true,
        throwHttpErrors: true,
        followRedirect: true,
        isStream: false,
        responseType: 'text',
        resolveBodyOnly: false,
        maxRedirects: 10,
        prefixUrl: [Getter/Setter],
        methodRewriting: true,
        ignoreInvalidCookies: false,
        http2: false,
        allowGetBody: false,
        https: undefined,
        pagination: {
          transform: [Function: transform],
          paginate: [Function: paginate],
          filter: [Function: filter],
          shouldContinue: [Function: shouldContinue],
          countLimit: Infinity,
          backoff: 0,
          requestLimit: 10000,
          stackAllItems: true
        },
        parseJson: [Function: parseJson],
        stringifyJson: [Function: stringifyJson],
        cacheOptions: {},
        username: '',
        password: '',
        url: <ref *4> URL {
          [Symbol(context)]: URLContext {
            flags: 400,
            scheme: 'http:',
            username: '',
            password: '',
            host: '127.0.0.1',
            port: 4040,
            path: [Array],
            query: null,
            fragment: null
          },
          [Symbol(query)]: URLSearchParams {
            [Symbol(query)]: [],
            [Symbol(context)]: [Circular *4]
          }
        },
        shared: undefined,
        cacheHeuristic: undefined,
        immutableMinTimeToLive: undefined,
        ignoreCargoCult: undefined,
        request: undefined,
        timeout: {},
        agent: undefined,
        [Symbol(isNormalizedAlready)]: true,
        [Symbol(request)]: [Function: request]
      },
      requestUrl: 'http://127.0.0.1:4040/api/tunnels',
      _cannotHaveBody: false,
      _noPipe: true,
      [Symbol(kCapture)]: false,
      [Symbol(downloadedSize)]: 105,
      [Symbol(uploadedSize)]: 74,
      [Symbol(serverResponsesPiped)]: Set(0) {},
      [Symbol(stopReading)]: true,
      [Symbol(triggerRead)]: false,
      [Symbol(jobs)]: [],
      [Symbol(body)]: '{"proto":"http","addr":1337,"name":"b6255ee7-3f9e-4b3b-9f6e-1471eaf44c77"}',
      [Symbol(bodySize)]: 74,
      [Symbol(cancelTimeouts)]: [Function: cancelTimeouts],
      [Symbol(unproxyEvents)]: [Function (anonymous)],
      [Symbol(request)]: <ref *3> ClientRequest {
        _events: [Object: null prototype] {
          abort: [Function: bound onceWrapper] {
            listener: [Function: onAbort]
          },
          socket: [Function (anonymous)],
          error: [ [Function], [Function] ],
          close: [Function: bound onceWrapper] {
            listener: [Function: cancelTimeouts]
          },
          connect: [Function (anonymous)],
          continue: [Function (anonymous)],
          information: [Function (anonymous)],
          upgrade: [Function (anonymous)],
          timeout: [Function (anonymous)],
          prefinish: [Function: requestOnPrefinish]
        },
        _eventsCount: 10,
        _maxListeners: undefined,
        outputData: [],
        outputSize: 0,
        writable: true,
        destroyed: false,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        maxRequestsOnConnectionReached: false,
        _defaultKeepAlive: true,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        _closed: false,
        socket: <ref *1> Socket {
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: null,
          _readableState: ReadableState {
            objectMode: false,
            highWaterMark: 16384,
            buffer: [BufferList],
            length: 0,
            pipes: [],
            flowing: true,
            ended: false,
            endEmitted: false,
            reading: true,
            constructed: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: false,
            resumeScheduled: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            destroyed: false,
            errored: null,
            closed: false,
            closeEmitted: false,
            defaultEncoding: 'utf8',
            awaitDrainWriters: null,
            multiAwaitDrain: false,
            readingMore: false,
            dataEmitted: true,
            decoder: null,
            encoding: null,
            [Symbol(kPaused)]: false
          },
          _events: [Object: null prototype] {
            end: [Function: onReadableStreamEnd],
            free: [Function: onFree],
            close: [Array],
            timeout: [Function: onTimeout],
            agentRemove: [Function: onRemove],
            error: [Function: socketErrorListener],
            finish: [Function]
          },
          _eventsCount: 7,
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: false,
            highWaterMark: 16384,
            finalCalled: true,
            needDrain: false,
            ending: true,
            ended: true,
            finished: false,
            destroyed: false,
            decodeStrings: false,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: false,
            bufferProcessing: false,
            onwrite: [Function: bound onwrite],
            writecb: null,
            writelen: 0,
            afterWriteTickInfo: null,
            buffered: [],
            bufferedIndex: 0,
            allBuffers: true,
            allNoop: true,
            pendingcb: 1,
            constructed: true,
            prefinished: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            errored: null,
            closed: false,
            closeEmitted: false,
            [Symbol(kOnFinished)]: []
          },
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: null,
          _server: null,
          parser: null,
          _httpMessage: [Circular *3],
          _peername: { address: '127.0.0.1', family: 'IPv4', port: 4040 },
          [Symbol(async_id_symbol)]: 396,
          [Symbol(kHandle)]: TCP {
            reading: true,
            onconnection: null,
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(kSetNoDelay)]: false,
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(RequestTimeout)]: undefined
        },
        _header: 'POST /api/tunnels HTTP/1.1\r\n' +
          'user-agent: got (https://github.com/sindresorhus/got)\r\n' +
          'content-type: application/json\r\n' +
          'accept: application/json\r\n' +
          'content-length: 74\r\n' +
          'accept-encoding: gzip, deflate, br\r\n' +
          'Host: 127.0.0.1:4040\r\n' +
          'Connection: close\r\n' +
          '\r\n',
        _keepAliveTimeout: 0,
        _onPendingData: [Function: nop],
        agent: Agent {
          _events: [Object: null prototype] {
            free: [Function (anonymous)],
            newListener: [Function: maybeEnableKeylog]
          },
          _eventsCount: 2,
          _maxListeners: undefined,
          defaultPort: 80,
          protocol: 'http:',
          options: [Object: null prototype] { path: null },
          requests: [Object: null prototype] {},
          sockets: [Object: null prototype] { '127.0.0.1:4040:': [Array] },
          freeSockets: [Object: null prototype] {},
          keepAliveMsecs: 1000,
          keepAlive: false,
          maxSockets: Infinity,
          maxFreeSockets: 256,
          scheduling: 'lifo',
          maxTotalSockets: Infinity,
          totalSocketCount: 1,
          [Symbol(kCapture)]: false
        },
        socketPath: undefined,
        method: 'POST',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: '/api/tunnels',
        _ended: true,
        res: [Circular *2],
        aborted: false,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: false,
        host: '127.0.0.1',
        protocol: 'http:',
        timings: {
          start: 1684481257959,
          socket: 1684481257960,
          lookup: 1684481257961,
          connect: 1684481257961,
          secureConnect: undefined,
          upload: 1684481257961,
          response: 1684481258068,
          end: 1684481258068,
          error: undefined,
          abort: undefined,
          phases: {
            wait: 1,
            dns: 1,
            tcp: 0,
            tls: undefined,
            request: 0,
            firstByte: 107,
            download: 0,
            total: 109
          }
        },
        emit: [Function (anonymous)],
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype] {
          'user-agent': [ 'user-agent', 'got (https://github.com/sindresorhus/got)' ],
          'content-type': [ 'content-type', 'application/json' ],
          accept: [ 'accept', 'application/json' ],
          'content-length': [ 'content-length', '74' ],
          'accept-encoding': [ 'accept-encoding', 'gzip, deflate, br' ],
          host: [ 'Host', '127.0.0.1:4040' ]
        },
        [Symbol(reentry)]: true
      },
      [Symbol(originalResponse)]: [Circular *2],
      [Symbol(isFromCache)]: false,
      [Symbol(responseSize)]: 105,
      [Symbol(response)]: [Circular *2],
      [Symbol(startedReading)]: true
    },
    isFromCache: false,
    ip: '127.0.0.1',
    retryCount: 0,
    rawBody: Buffer(105) [Uint8Array] [
      123,  34, 101, 114, 114, 111, 114,  95,  99, 111, 100, 101,
       34,  58,  49,  48,  51,  44,  34, 115, 116,  97, 116, 117,
      115,  95,  99, 111, 100, 101,  34,  58,  53,  48,  50,  44,
       34, 109, 115, 103,  34,  58,  34, 102,  97, 105, 108, 101,
      100,  32, 116, 111,  32, 115, 116,  97, 114, 116,  32, 116,
      117, 110, 110, 101, 108,  34,  44,  34, 100, 101, 116,  97,
      105, 108, 115,  34,  58, 123,  34, 101, 114, 114,  34,  58,
       34, 114, 101, 109, 111, 116, 101,  32, 103, 111, 110, 101,
       32,  97, 119,  97,
      ... 5 more items
    ],
    body: '{"error_code":103,"status_code":502,"msg":"failed to start tunnel","details":{"err":"remote gone away"}}\n',
    [Symbol(kCapture)]: false,
    [Symbol(kHeaders)]: {
      'content-type': 'application/json',
      date: 'Fri, 19 May 2023 07:27:38 GMT',
      'content-length': '105',
      connection: 'close'
    },
    [Symbol(kHeadersCount)]: 8,
    [Symbol(kTrailers)]: null,
    [Symbol(kTrailersCount)]: 0,
    [Symbol(RequestTimeout)]: undefined
  },
  body: {
    error_code: 103,
    status_code: 502,
    msg: 'failed to start tunnel',
    details: { err: 'remote gone away' }
  }
}
error Command failed with exit code 7.

The error msg is very long, these are just part of it.

Hi @peh1696

Based on the error message it looks like some issue with the connection. If you have any VPN or some blockers try disabling it.

msg: 'failed to start tunnel',
    details: { err: 'remote gone away' }

Hi @johnversus,
Thanks for the reply, I don’t have VPN

These are the method i have tried and still not working:

  1. Added allowed port 4040 in windows defender
  2. Disable windows defender and norton 360.

Seems like the issue is related to Ngrok, may i know do i need to install anything else other than Node version 16?

Is the parse server migration project workable in Win 10?

how are you using ngrok? that error seems to be from ngrok

Is there anything i needed to set on ngrok?

At 1st, i install those needed components with “yarn install” command.
Then, successfully built the project with “yarn build” command.

I got those error msg when i try to run the project. Do i need to run ngrok or something?

Do i need to download and install ngrok app from ngrok.com?

After tried for a few methods, finally fixed it by re-installing the ngrok by using the command “yarn add ngrok”.

4 Likes

The Moralis’ migration template is outdated, hence problems

1 Like