I’m trying to deploy a next.js application using express to electric beanstalk and I’m getting constant 502 Bad Gateway errors.
2020/03/02 15:26:28 [error] 8286#0: *172 connect() failed (111: Connection refused) while connecting to upstream, client: 109.190.231.251, server: , request: "GET /db/websql/index.php?lang=en HTTP/1.1", upstream: "http://127.0.0.1:8081/db/websql/index.php?lang=en", host: "54.244.187.52"
I’ve read that this could be a port issue (:8081) so I have configured a PORT env variable in the software configuration. This isn’t fixing the issue. And my port is set as follows in my express server:
const PORT = process.env.PORT || 8081;
I’m using the
us-west-2
region.
I have an EB config file in the .ebextensions directory which reads 'npm start' and that looks like the following in my package.json
"start": "NODE_ENV=production next build && NODE_ENV=production node ./server.js",
Everything runs fine locally in both dev and prod modes but I can’t seem to get it running on EB.
Any help would be very much appreciated!
next build
in the start command??? There must be a better way... – NSjonas