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

Help Needed: Cloud Run Deployment Issue - Container Failed to Listen on Port 8080

Hello , community.

I am encountering an issue while deploying my containerized application on Google Cloud Run. The Docker image builds successfully, but when I try to run it, I receive an error indicating that the container failed to listen on port 8080. Below are the details of my setup, the error message, and the Dockerfile used:

Error Message - "Ready condition status changed to False for Service blog-service with message: Revision 'blog-service-00001-khj' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
"

Here's My Dockerfile

# Use an official Node.js runtime as a parent image
FROM node:18-alpine

# Set the working directory in the container
WORKDIR /app

# Install pnpm globally and clean npm cache to reduce image size
RUN npm install -g pnpm && npm cache clean --force

# Copy package.json and pnpm-lock.yaml (if available)
COPY package.json pnpm-lock.yaml ./

# Install dependencies
RUN pnpm install

# Copy the rest of the application code
COPY . .

# Build the application
RUN pnpm run build

# Expose the port the app runs on (default for Cloud Run is 8080)
EXPOSE 8080

# Define the command to run the application
CMD ["pnpm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8080"]

Any Help Would Be Much Appreciated.
Thanks In Advance.

Solved Solved
0 6 18.9K
1 ACCEPTED SOLUTION

First of all, the error message ‘Revision ‘blog-service-00001-khj’ is not ready and cannot serve traffic’ means that the server is not responding. Generally, this indicates that the server is in a state where it cannot properly receive requests.

My guess is that port 8080 might not have been opened correctly.

Try this.

CMD ["pnpm", "run", "preview", "--host", "0.0.0.0", "--port", "8080"]

instead of

CMD ["pnpm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8080"]

 

View solution in original post

6 REPLIES 6

First of all, the error message ‘Revision ‘blog-service-00001-khj’ is not ready and cannot serve traffic’ means that the server is not responding. Generally, this indicates that the server is in a state where it cannot properly receive requests.

My guess is that port 8080 might not have been opened correctly.

Try this.

CMD ["pnpm", "run", "preview", "--host", "0.0.0.0", "--port", "8080"]

instead of

CMD ["pnpm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8080"]

 

Thanks @apeltop 

I am trying to pull a public docker image and it is giving me same port 8080 error. The command you gave above right, I tried that in cloud shell but it is giving me this error: -bash: [pnpm,: command not found. Can you kindly help me on it please.

Hi SankariJay 

First of all, I don't know what exactly you want. So let me answer the error you mentioned.

Cloud Run is a serverless service. So you can't connect to a Cloud Run instance. You need to do the work in your Dockerfile.

See also
Example 1: Build a Bundle in a Docker Container https://pnpm.io/docker#example-1-build-a-bundle-in-a-docker-container

I was getting the same error message; however, in my case it was `gunicorn` to serve. I spent hours trying out so many suggestions here and there, but none worked for me! So tried to run the same docker image locally, it was then I noticed my silly mistake: "unable to start container process: exec: "gunicorn": executable file not found in $PATH: unknown."

So, yes, `gunicron` package was missing from my `requirements.txt` file! I updated the file and tried again and everything started to work just fine; hope this helps.

If it was previously working and has stopped working now. I observed that if I close the session and come back to it later, the settings change for some reason.

Please check.
1. Your Service Settings

sathish297_0-1731765565697.png

 

2. Container image url

sathish297_2-1731765636346.png

 

3. Docker file in build settings

sathish297_3-1731765668104.png