Google App Engine - An error occurred while requesting the API

System Information
  • Strapi Version: 4.5.2
  • Operating System: Windows 11
  • Database: MySQL
  • Node Version: 16.17.1
  • NPM Version: 8.15.0
  • Yarn Version: 1.22.19

I’ve been using strapi for quite a while but only on self hosted systems and for smaller projects.

I now want to host a Strapi-App on Google App Engine and using a MySQL-Database but I don’t seem to be able to quite do so. I followed the guide as close as possible and I think I’m very close but even after looking through several logs and googleing for hours I don’t seem to be able to fix it.

The “front-page” of strapi shows up perfectly stating “The server is running successfully.” and showing the environment as “Production” but as soon as I try to access /admin I get the error:
“Warning: An error occurred while requesting the API”

The Strapi-Server doesn’t seem to log anything according to the Google App Engine Logs, but the Borwser shows me an axios-error. It seems that axios tries to call a GET function on localhost:1337. That seems to be the error but I don’t know why and how to fix it.


runtime: nodejs16
instance_class: F2

  HOST: ''
  NODE_ENV: 'production'
  DATABASE_HOST: '*******'
  DATABASE_NAME: '*******'
  DATABASE_PASSWORD: '*********'
  INSTANCE_CONNECTION_NAME: 'my-app-name:europe-west6:my-app-name'
  APP_KEYS: '***'
  JWT_SECRET: '***'

  cloud_sql_instances: 'my-app-name:europe-west6:my-app-name'

The database connection seems to work properly since all the tables have been created.

Thank you for your help.

I’m having a similar problem, how did you use the /config/database.js to connect?

This is the content of my file in /config/env/production/database.js

module.exports = ({ env }) => ({
    connection: {
      client: 'mysql',
      connection: {
        host: env('DATABASE_HOST', ''),
        port:'DATABASE_PORT', 3306),
        database: env('DATABASE_NAME', 'strapi'),
        user: env('DATABASE_USERNAME', 'strapi'),
        password: env('DATABASE_PASSWORD', 'strapi'),
        ssl: {
          rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), // For self-signed certificates
      debug: false,

Sorry for the unrelated question, but why is your path /config/env/production/database.js while mine is /config/database.js, does that matter on Strapi 4.4.5?

Running it with

"gcp-build": "strapi build && strapi develop"

You can use different config files for different environments.
If you have the file for example: /config/database.js it will be loaded every time. If you have it in /config/env/production/database.js it will be loaded when you run in production.

This way you can have a different database for production and development. I use SQLite in development and MySQL in productin for example.

(At least this is how I understand it)

Oh I see, makes sense. Yeah, I was wondering if that was part of the issue that I have as well. I actually can’t even connect to the DB. Have Cloud SQL Admin enabled, using a Postgres DB.

Did you experience this issue before? :stuck_out_tongue:

Building your admin UI with development configuration...
Admin UI built successfully
[2022-12-07 20:04:45.755] debug: \u26d4\ufe0f Server wasn't able to start properly.
[2022-12-07 20:04:45.756] error: connect ENOENT /cloudsql/project:region:db/.s.PGSQL.5432
Error: connect ENOENT /cloudsql/project:region:db/.s.PGSQL.5432
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)

Mh, no Sorry I don’t think I know anything about that… Looks like a Problem with Postgres for which I sadly don’t have too much experience.

Thank you for taking the time to go over that, Lukas. Not too many info on this out there. And sorry for not being of much help in regards of your post.

I was able to fix my problem.

I forgot to add the "gcp-build": "strapi build" to the scripts in the package.json which stopped google app engine from building the app after deployment.

1 Like