Trouble launching Go backend on Google Cloud Run: Port 8080 issues

Hi folks,

I’m stuck trying to get my Go backend up and running on Google Cloud Run. I keep running into a port 8080 error, even though both my Dockerfile and main.go are configured to use that port (with main pulling the value from the .env file).

I’ve searched everywhere, including watching YouTube tutorials and asking ChatGPT, but nothing has worked so far. This deployment is urgent as it needs to be live by Sunday, so I’m really feeling the pressure.

Any tips or workarounds would be greatly appreciated. Thanks a bunch!

Update:
I managed to overcome the initial issue by running db.Connect in the background. Cloud Run accepted it without any errors, indicating the problem was with the database connection. However, I now face a new challenge: switching from a third-party database service to Cloud SQL. I’m encountering errors while importing my existing database, and time is running short on this project (it’s complete, just needs deployment). Any ideas?

Having faced similar deployment challenges, I can relate to your frustration. For the Cloud SQL issue, consider using the Cloud SQL Auth proxy for secure connections. It’s a reliable method that bypasses many common import problems. If time permits, try a manual data export from your current database and then import it directly into Cloud SQL using their native tools. This approach often circumvents compatibility issues. Additionally, double-check your connection string and ensure your Cloud Run service has the necessary IAM permissions to access Cloud SQL. If all else fails, a temporary solution might be to stick with your current database setup for now and migrate to Cloud SQL post-launch when you have more time to troubleshoot thoroughly.

hey there, sry to hear bout ur troubles. have u tried checkin the logs in cloud run? sometimes they give hints bout whats goin wrong. for the cloud sql thing, maybe try usin the gcloud command line tool to import ur data? its pretty straightforward. if ur really in a time crunch, u could always stick with ur current db for now and switch later when u got more time to figure it out. good luck!

hey there! sounds like you’re in a bit of a pickle. have you considered using a database migration tool like flyway or liquibase? they can make importing data to cloud sql way easier. also, whats your connection string look like? sometimes a tiny typo can cause big headaches. keep us posted on how it goes!