Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Cloud Run Showing "Listen On This Port Error"

I am using cloud run. I pull docker images, then push them directly to a google container registry and then link them to Cloud Run Service. However, when I try to deploy Cloud Run Service I don't know why every time this show me this error

Cloud Run error: Container failed to start. 
Failed to start and then listen on the port defined by the PORT environment variable. 
Logs for this revision might contain more information.

Please, someone, give me any solution and what is actually saying which file should I change or which kind of change should I made??

like image 349
WordpressFixer Avatar asked Jan 01 '23 16:01

WordpressFixer


2 Answers

It's the default error message when the container don't start, even if you have well defined the port to listen.

Go to the logs and see what exactly happens. You could fix the start with the correct message.

like image 58
guillaume blaquiere Avatar answered Jan 03 '23 05:01

guillaume blaquiere


When you provide a container image to Cloud Run, that contain has a contract that it must fulfill in order to operate correctly. Please read that contract, especially the part about listening on a port:

Listening for requests on PORT

The container must listen for requests on 0.0.0.0 on the port defined by the PORT environment variable.

In Cloud Run container instances, the PORT environment variable is always set to 8080, but for portability reasons, your code should not hardcode this value.

Your container must be running a processing that's listening on port 8080, or whatever the PORT environment variable is. If it's not doing that, it can't receive incoming requests.

See also Cloud Run troubleshooting documentation.

like image 40
Doug Stevenson Avatar answered Jan 03 '23 04:01

Doug Stevenson