Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google cloud run deploy error: The user-provided container failed to start and listen on the port

I am trying to source deploy a docker container from a github repo to google cloud run to serve a webapp.

I keep getting a TCP health check error saying "Revision 'xxxx' is not ready and cannot serve traffic. The userprovided container failed to start and listen on the port defined provided by the PORT=8000 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short."

However, I have my timeouts at the maximum allowed values like so

Startup probetcp 8000 every 240s     
Initial delay    240s
Timeout    240s
Failure threshold    1
 
The container works and exposes the right port in a local run but I can't figure out why the google run deploy constantly fails. Any ideas on how to address this?
 
I have also tried adding  
ENV HOSTNAME="0.0.0.0"
ENV HOST="0.0.0.0"
to my dockerfile as was suggested by some other answers to no avail.
 
I also pulled down the image built by google cloud using gcloud cli and tested it locally and it seems to start the server and serve the webapp fine. 
 
Any help will be much appreciated.
0 6 1,582
6 REPLIES 6

Provide a copy of the contents of your docker file.

   ......NoCommandLine ......
https://nocommandline.com
Analytics & GUI for App Engine,
Cloud Run & Datastore Emulator

Here is the repo which I am trying to deploy: https://github.com/innuo/FactSimply

And this is the dockerfile:

 

# pull latest julia image
FROM --platform=linux/amd64 julia:latest

# create dedicated user
RUN useradd --create-home --shell /bin/bash genie

# set up the app
RUN mkdir /home/genie/app
COPY . /home/genie/app
WORKDIR /home/genie/app

# configure permissions
RUN chown -R genie:genie /home/

RUN chmod +x bin/repl
RUN chmod +x bin/server
RUN chmod +x bin/runtask

# switch user
USER genie

# instantiate Julia packages
RUN julia -e "using Pkg; Pkg.activate(\".\"); Pkg.instantiate(); Pkg.precompile(); "

# ports
EXPOSE 8000
EXPOSE 80

# set up app environment
ENV JULIA_DEPOT_PATH="/home/genie/.julia"
ENV GENIE_ENV="prod"
ENV GENIE_HOST="0.0.0.0"
ENV PORT="8000"
ENV WSPORT="8000"
ENV EARLYBIND="true"
ENV HOSTNAME="0.0.0.0"
ENV HOST="0.0.0.0"
 
CMD ["bin/server"]

I've been able to confirm that if I run the container on the google cloud engine with the `-p 8000:8000` argument I can curl to 0.0.0.0:8000, but if I just did `docker run` without the -p option then I get no response.

How does google cloud run run the container? It appears that the 8000 port that I picked in the configuration console is not getting used to route requests to the container port.

Hi @innuo,

Just wanted to jump into the thread. Could you check if changing the port to 8080 helps? From the Container runtime contract, Cloud Run requests are sent to port 8080 by default.

Since you’ve already verified that your container works locally, another troubleshooting step I can suggest is to confirm that your container image is compiled for 64-bit Linux as required by the container runtime contract.

Another option we can try is to run a Connectivity Test and then share your test results here. I also found this thread on Stack Overflow where the user was able to resolve their container issue by doing a Startup Probe healthcheck.

Was my response helpful? If so, feel free to accept this answer as “Solution”. If you need any additional assistance you may also reply here within two business days. Share your logs, screenshots, or any additional errors you might have received and I’ll be happy to help.

@-Rhett Thanks for the suggestions. I am using google cloud build (deploying from source from repo on github) so the platform should not be an issue (I tried having both `FROM --platform=linux/amd64 julia:latest` and `FROM julia:latest` in my dockerfile)

Also I thought that choosing the port as 8000 overrides the default port of 8080. I've

done it like so.Screenshot 2024-12-27 at 10.01.41 AM.png

I am having the same issue, I am trying to deploy a new image of the same codebase that was working one month ago (no app or build changes made) to test it and I get the same error.

comparing the yaml files, these are the main diffs

the google apis is different

Screenshot 2025-01-13 at 21.27.21.png

this is where it shows the error logs

Screenshot 2025-01-13 at 21.27.36.png