question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deployment is returning 502: BAD_GATEWAY error

See original GitHub issue

I am trying to sort out what is causing the error. Here is the error from the Build Logs:

12:52:57.034 | ┌──────────────────────────────┐
-- | --
12:52:57.035 | │ built server with 2 warnings │
12:52:57.035 | └──────────────────────────────┘
12:52:57.035 | > 'images/successkid.jpg' is imported by src/routes/index.svelte, but could not be resolved – treating it as an external dependency
12:52:57.035 | > Entry module "src/server.ts" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "src/server.ts" to use named exports only.

I am thinking the 2nd error could be the main problem with the deploy. Here is what my server.ts file shows:

import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';

const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';

export default polka() // You can also use Express
	.use(
		compression({ threshold: 0 }),
		sirv('static', { dev }),
		sapper.middleware()
	)
	.listen(PORT, err => {
		if (err) console.log('error', err);
	});

However, when I run vercel in the CLI I get this error:

Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply.

I assume that the mentioned “configuration file” is vercel.json. Mine looks like this:

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "vercel-sapper"
    }
  ]
}

Does anyone have guidance on how to fix the 502: BAD_GATEWAY error I am experiencing? Thank you in advance for any assistance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kostiatocommented, Oct 25, 2020
-node_modules
+/node_modules

unfortunately this didn’t help.

2reactions
thghcommented, Oct 19, 2020

I think the .vercelignore blocks the upload of src/node_modules

This change could fix it:

-node_modules
+/node_modules
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Kubernetes '502 Bad Gateway' Error - Komodor
A 502 Bad Gateway error is an 5xx server error that indicates a server received an invalid response from a proxy or gateway...
Read more >
How to Fix 502 Bad Gateway Error - Hostinger
This article will go over some troubleshooting steps to follow when a 502 Bad Gateway error occurs, both for the server and client-side....
Read more >
What is a 502 Bad Gateway and how do you fix it? - IT PRO
An Error 502 Bad Gateway means there is a problem with the website's server, rather than your computer, router, or internet connection. It's...
Read more >
502 Bad Gateway Error: What It Is and How to Fix It
As mentioned, a 502 Bad Gateway Error means the client is having difficulty connecting to a server. This means that the server creating...
Read more >
trying to debug "502 Bad Gateway" error after deploying react ...
"An error code 502 with BAD_GATEWAY in the message usually indicates that App Engine terminated the application because it ran out of memory....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found