Subscribe Now

* You will receive the latest news and updates on your favorite celebrities!

Trending News

Blog Post

FIXED: Cloud Run – Failed to start and then listen on the port defined by the PORT
DevOps

FIXED: Cloud Run – Failed to start and then listen on the port defined by the PORT 

While deploying a web app like React, Angular or Node projects using Google cloud, you might come across this error after pushing your app from a docker container to gcr.io (Google cloud repository)

After tracing the logs, i realised its a platform related problem and you must have built your docker image using the code below;

docker  build -t {project-name} . 

The code above works well on an intel system when you push to Google Cloud. but not on Apples M1, sadly 🙁

You will get an error saying:

Cloud Run: “Failed to start and then listen on the port defined by the PORT environment variable.”

this happens when building on Cloud run
cloud run issue environment variable

Solution to the Cloud run Failed to start issue

Use the following command to build your docker image;

docker buildx build --platform linux/amd64 -t {project-name} .

Voila! 😀

Watch how to Deploy a React app on Cloud run

Related posts

4 Comments

  1. Daniel

    Hello,

    I am encountering the same issue, but even using buildx I receive the following error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable.

    Do you have any ideas on how to solve this problem?

    1. Vinay

      Hi Daniel, is this a new container or an existing project? I’ll suggest you use a different gcr

      1. Neba

        I have same problem. What gcr will you recommend

  2. name

    Hi, can you please tell me why it works? Thanks for the solution it works for me!

Leave a Reply

Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.