Network error: Response not successful: Received status code 502

Hi everyone!

I ran into a problem when attempting to deploy a Redwood app with a postgres database.

Following along with the tutorial, I provisioned a postgress DB on Heroku. I than got the URI and set an environment variable (DATABASE_URL) on the netlify instance of a Redwood app I built.

When I deployed the app, I got the following console error:
“Network error: Response not successful: Received status code 502”

Any suggestions on how to debug?

1 Like

Hi @joshsaintjacque!

Would you be able to share the deployed URL so we can check it out?

Or do you mean the app never even deployed and the error showed in Netlify’s console?
A full dump of the logs might be helpful then :slight_smile:

I ran into the a 502 issue as well.

Mine was solved with this: https://community.netlify.com/t/debugging-a-function-returns-502/429

Hopeful escaping the response better will solve yours!

1 Like

@olance Sure thing, it’s at:
https://suspicious-yonath-9779fa.netlify.com/jobs

@janmechtel Thanks! I’ll take a look.

@olance It did succeed in deploying, but there were errors in the netlify logs.

Specifically, I think this is most relevant:

11:38:21 PM: Migrate database up... [started]
11:38:22 PM: $ /opt/build/repo/node_modules/.bin/prisma2 migrate up --experimental --create-db
11:38:23 PM: Response "Error in connector: The database URL is not valid"
11:38:23 PM: Got result for unknown id undefined
11:38:23 PM: Error: Error in migration engine: Apr 12 06:38:23.051  INFO migration_engine: Starting migration engine RPC server git_hash="8814060fa684793b73d07dbfccd4b7777b3361ae"
11:38:23 PM: Migrate database up... [completed]

I’ve confirmed the database url (as specified as the DATABASE_URL env variable) is valid. I can cannot via postico.

And here are the full logs:

11:37:15 PM: Build ready to start
11:37:17 PM: build-image version: 2dbd444fcdce00cf06325060a8238d5ae3e86774
11:37:17 PM: build-image tag: v3.3.7
11:37:17 PM: buildbot version: 7f867b365e4c3934ca5b72b9d51f0a4d1f96685d
11:37:17 PM: Fetching cached dependencies
11:37:17 PM: Starting to download cache of 234.3MB
11:37:22 PM: Finished downloading cache in 5.431358644s
11:37:22 PM: Starting to extract cache
11:37:32 PM: Finished extracting cache in 10.264318492s
11:37:33 PM: Finished fetching cache in 15.75035745s
11:37:33 PM: Starting to prepare the repo for build
11:37:33 PM: Preparing Git Reference refs/heads/master
11:37:33 PM: Found Netlify configuration file netlify.toml in site root
11:37:33 PM: Found Netlify configuration file(s). Overriding site configuration
11:37:33 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'api/dist/functions' versus '' in the Netlify UI
11:37:33 PM: Creating functions prep folder
11:37:33 PM: Starting build script
11:37:34 PM: Installing dependencies
11:37:34 PM: Started restoring cached node version
11:37:38 PM: Finished restoring cached node version
11:37:38 PM: Attempting node version 'lts/*' from .nvmrc
11:37:39 PM: v12.16.2 is already installed.
11:37:39 PM: Now using node v12.16.2 (npm v6.14.4)
11:37:39 PM: Attempting ruby version 2.6.2, read from environment
11:37:40 PM: Using ruby version 2.6.2
11:37:41 PM: Using PHP version 5.6
11:37:41 PM: Started restoring cached node modules
11:37:41 PM: Finished restoring cached node modules
11:37:41 PM: Started restoring cached yarn cache
11:37:41 PM: Finished restoring cached yarn cache
11:37:41 PM: Installing NPM modules using Yarn version 1.17.0
11:37:42 PM: yarn install v1.17.0
11:37:42 PM: [1/5] Validating package.json...
11:37:42 PM: [2/5] Resolving packages...
11:37:42 PM: [3/5] Fetching packages...
11:38:04 PM: info fsevents@1.2.11: The platform "linux" is incompatible with this module.
11:38:04 PM: info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
11:38:04 PM: info fsevents@2.1.2: The platform "linux" is incompatible with this module.
11:38:04 PM: info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:38:04 PM: [4/5] Linking dependencies...
11:38:04 PM: warning "@redwoodjs/core > @testing-library/react@10.0.2" has unmet peer dependency "react@*".
11:38:04 PM: warning "@redwoodjs/core > @testing-library/react@10.0.2" has unmet peer dependency "react-dom@*".
11:38:17 PM: [5/5] Building fresh packages...
11:38:20 PM: Done in 38.63s.
11:38:20 PM: NPM modules installed using Yarn
11:38:20 PM: Started restoring cached go cache
11:38:20 PM: Finished restoring cached go cache
11:38:20 PM: unset GOOS;
11:38:20 PM: unset GOARCH;
11:38:20 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
11:38:20 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
11:38:20 PM: go version >&2;
11:38:20 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
11:38:20 PM: go version go1.12 linux/amd64
11:38:20 PM: Installing missing commands
11:38:20 PM: Verify run directory
11:38:20 PM: Executing user command: yarn rw db up --no-db-client && yarn rw build
11:38:21 PM: yarn run v1.17.0
11:38:21 PM: $ /opt/build/repo/node_modules/.bin/rw db up --no-db-client
11:38:21 PM: Migrate database up... [started]
11:38:22 PM: $ /opt/build/repo/node_modules/.bin/prisma2 migrate up --experimental --create-db
11:38:23 PM: Response "Error in connector: The database URL is not valid"
11:38:23 PM: Got result for unknown id undefined
11:38:23 PM: Error: Error in migration engine: Apr 12 06:38:23.051  INFO migration_engine: Starting migration engine RPC server git_hash="8814060fa684793b73d07dbfccd4b7777b3361ae"
11:38:23 PM: Migrate database up... [completed]
11:38:23 PM: Done in 1.98s.
11:38:23 PM: yarn run v1.17.0
11:38:23 PM: $ /opt/build/repo/node_modules/.bin/rw build
11:38:24 PM: Generating the Prisma client... [started]
11:38:26 PM: Generating the Prisma client... [completed]
11:38:26 PM: [06:38:26] Building "api"... [started]
11:38:27 PM: [06:38:27] Building "api"... [completed]
11:38:27 PM: [06:38:27] Building "web"... [started]
11:38:45 PM: [06:38:45] Building "web"... [completed]
11:38:45 PM: Done in 22.37s.
11:38:45 PM: Function Dir: /opt/build/repo/api/dist/functions
11:38:45 PM: TempDir: /tmp/zisi-5e92b71b71160900079a5ed4
11:38:46 PM: Prepping functions with zip-it-and-ship-it 0.3.1
11:38:58 PM: [ { path: '/tmp/zisi-5e92b71b71160900079a5ed4/graphql.zip',
11:38:58 PM:     runtime: 'js' } ]
11:38:58 PM: Prepping functions complete
11:38:58 PM: Caching artifacts
11:38:58 PM: Started saving node modules
11:38:58 PM: Finished saving node modules
11:38:58 PM: Started saving yarn cache
11:38:58 PM: Finished saving yarn cache
11:38:58 PM: Started saving pip cache
11:38:58 PM: Finished saving pip cache
11:38:58 PM: Started saving emacs cask dependencies
11:38:58 PM: Finished saving emacs cask dependencies
11:38:58 PM: Started saving maven dependencies
11:38:58 PM: Finished saving maven dependencies
11:38:58 PM: Started saving boot dependencies
11:38:58 PM: Finished saving boot dependencies
11:38:58 PM: Started saving go dependencies
11:38:58 PM: Finished saving go dependencies
11:38:58 PM: Build script success
11:38:58 PM: Starting to deploy site from 'web/dist'
11:38:58 PM: Creating deploy tree 
11:38:58 PM: Creating deploy upload records
11:38:58 PM: 19 new files to upload
11:38:58 PM: 1 new functions to upload
11:39:01 PM: Starting post processing
11:39:01 PM: Post processing done
11:39:02 PM: Site is live
11:39:47 PM: Finished processing build request in 2m29.91403919s

@joshsaintjacque Is is possible that you 1) are now deploying using Redwood v0.4.0 but 2) had initially/previously deployed using an earlier version of Redwood?

There were breaking changes to Prisma Migrations between their preview024 and preview025 versions. I have suggestions or workaround if this might have happened to you.

Have you tried using that same database URL locally during development?

1 Like

Might not be it, but I’ve seen this error today about the DATABASE_URL when I forgot to change my DB provider from postgresql to sqlite locally… Could this be the source of your error, the other way round though?

3 Likes

@olance That was it! Thank you so much, I was struggling with that one.

Edit: Darn, I spoke too soon. I was able to fix the local repro by switching the provider, however pushing the change to netlify doesn’t fix the 502.

2 Likes

Did you see the recent Redwood-Netlify plugin from @rob that allows you to keep the provider at ‘sqlite’ and update to postgres via Env Var (or just automatically by default) in Netlify? It’s only been available for about a week and is now included in the Tutorial. It will be highlighted in our next full release.

Check it out if you haven’t seen it!

1 Like

Thanks @thedavid I’ll check it out!

1 Like