0

I'm new to GCP (google cloud platform) I'm facing this problem, Backend dev created an Apache server on gcp, and then I cloned my repo on the server through VM, build it and then deployed it after following countless tutorials.. but while deploying it gives

Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.

when i go to the generated link which is https://vetution.oa.r.appspot.com/ it gives server error, I've searched a lot but I failed. Have I done something wrong or the app.yaml file should have different configurations.

anyway here it is

runtime: nodejs12
instance_class: F2
handlers:
  - url: /_nuxt
static_dir: .nuxt/dist/client
secure: always
 - url: /(.*\.(gif|png|jpg|ico|txt))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg|ico|txt)$
secure: always
 - url: /.*
script: auto
secure: always
env_variables:
HOST: '0.0.0.0'
NODE_ENV: 'production'

And It gives me this error on deploying now

please, Help me I'm very frustrated.

Abdelrhman Gad
  • 195
  • 2
  • 11

1 Answers1

2

The error states that, your app failed to start because it's not listening to a port as you may not have configure it to your app. This topic is answered on this Stackoverflow thread.

You mentioned that you followed countless tutorials, it is possible that you are using Cloud Run and App Engine interchangeably, which are 2 separate serverless products. Please evaluate on your end which platform is right for your app and use case.

Currently, there is not much debugging info to your question but either way, make sure that you configure your app's port to listen to incoming request/s, it can be port 8080 or can be any of your choice. Also, check your GCP logs, backend issues and server errors can be seen and monitored by simply looking at the logs for App Engine or Cloud Run.

Check Cloud Run configuring the container ports, for port configuration.

Donnald Cucharo
  • 3,866
  • 1
  • 10
  • 17
Bryan L
  • 550
  • 1
  • 9
  • Thank you very much for your help, I've decided to go with cloud-run, At nuxt-config file I made a server key and gave it a port 8080 and then I also configured cloud run container port to 8080, and tried to deploy again but I got the same error!, Where should I set that port other than those two places? – Abdelrhman Gad Oct 26 '21 at 17:52
  • @AbdelrhmanGad you can check out this Github link, it might help you. https://github.com/fireship-io/179-cloud-run-ssr/blob/master/server/index.js – Bryan L Oct 27 '21 at 07:13