[Solved]-Google App Engine logs a mess of New connection for … and Client closed local connection on

2👍

I found this post where it’s mentioned that setting -verbose=false will turn off the new/closed connection logs.

0👍

I found information about the same error but it wasn’t generating a lot of connections. Anyway it was related to the Cloud SQL proxy.

Have you followed the instructions in this guide to configure the PostgreSQL connection to App Engine? I am particularly interested in the ones from “Setting up your local environment”.

I did not found any related field in quotas or pricing pages but you can check the billing in the Google Cloud Console: Billing -> Overview -> [PROJECT_ID].

0👍

I’m not a django developer but I guess the root of this problem is that django opens a new connection to the database for every request by default.

Source: https://docs.djangoproject.com/en/2.1/ref/databases/

Persistent connections avoid the overhead of re-establishing a connection to the database in each request. They’re controlled by the CONN_MAX_AGE parameter which defines the maximum lifetime of a connection. It can be set independently for each database.

The default value is 0, preserving the historical behavior of closing
the database connection at the end of each request. To enable
persistent connections, set CONN_MAX_AGE to a positive number of
seconds. For unlimited persistent connections, set it to None.

You can try to increase the CONN_MAX_AGE or set it to None and the log messages should disappear.

0👍

Changing CONN_MAX_AGE value to None can help, however this may expose your application to bot attacks like exposed me (see the picture below):

Google Cloud Platform

Looking for the IP’s in abuseIPDB.com I’ve found a lot of reports of Brute Force/Web App Attack from it.

Maybe setting the variable value to a fixed number may keep your application safe and stop these logs.

Leave a comment