Rails app running on Google App Engine, but can't save to Postgres database

127 views
Skip to first unread message

Craig DesBrisay

unread,
Oct 18, 2017, 10:33:58 AM10/18/17
to Google App Engine
I have successfully deployed my Ruby on Rails application to Google App Engine. I can browse a couple of the pages and everything seems fine. However, when I try to submit the user signup form I keep getting either a 502 bad gateway or 500 error.

It seems like maybe the app is not able to save to the Postgres database on my Cloud SQL instance?

I have double and triple checked that my settings in my app.yaml file are correct for:
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DATABASE
  • POSTGRES_SOCKET_PATH
Also in my app.yaml file I have set the following:

beta_settings:
  cloud_sql_instances: 'my-project-id':us-east1:topicurious-dev

I wonder if it's an IAM permissions problem? 

I have set 'my-project-id'@@appspot.gserviceaccount.com member to be a Cloud SQL Editor and Cloud SQL Client.

My Cloud SQL (postgres) instance also has a 'insert-cryptic-id-here'@speckle-umbrella-pg-5.iam.gserviceaccount.com. Do I need to somehow tell the App Engine instance that it needs to connect to that service account to save to the db?

Kenworth (Google Cloud Platform)

unread,
Oct 18, 2017, 1:56:52 PM10/18/17
to Google App Engine
Quick question: Are you using GAE Standard or Flexible environment?

Craig DesBrisay

unread,
Oct 18, 2017, 11:40:32 PM10/18/17
to Google App Engine
Flexible environment. The instructions in the tutorials say to specify "flex" environment in the app.yaml file.

https://cloud.google.com/ruby/rails/using-cloudsql-postgres 

Is it possible to run Ruby/Rails in a GAE Standard environment? If yes, how do I properly specify it in the app.yaml file?

George (Cloud Platform Support)

unread,
Oct 19, 2017, 2:53:42 PM10/19/17
to Google App Engine
Hello Craig, 

There are three main options for deploying Rails on Cloud Platform, none of which specifies the standard environment: Google App Engine Flexible Environment, Google Container Engine, Google Compute Engine, as specified on the "Running Rails on Google Cloud Platform" documentation page

Rails ActiveRecord works best with a traditional SQL database. If you are starting a new project, Google Cloud SQL is a good choice. With a few clicks you can create a MySQL or PostgreSQL database that is fully managed and scaled by Google, with no management on your end. You can learn more by reviewing the Using Cloud SQL for MySQL with Rails 5tutorial or the Using Cloud SQL for PostgreSQL with Rails 5.

This forum is meant for general discussion and voicing of opinions; for coding-related issues you may get better results posting on forums such as stackoverflow, where competent programmers are ready to help. 
Reply all
Reply to author
Forward
0 new messages