Behaviour different in local dev vs render


I have a flask CRUD app using a render DB which works fine when I deploy it to prod on here, when I use it locally on my laptop (still using the render DB) and the external URL provided, it only let’s me list items in DB, but when I try and add to them it silently fails (no error logs on DB or Flask app even on debug).

Given the connection must be working for it to list items locally, is there any reason why adding items would fail locally?

Hi there,

Thanks for reaching out.

If you’re referring to a Render Postgres instance, you’d need to ensure that the access controls are set to permit you to connect from your local environment, however with the default credentials, this would allow read & write, not just read as you described.

If you could share some more specific examples of the issue you are experiencing that may help us troubleshoot it with you, e.g. any logs/errors/output, specific URLs, service name/ID, reproduction steps, etc. If you don’t want to share these details on the community forum, please feel free to raise a ticket with



Thank you for the reply. Happy to put here. The code is here:

When being run on render it is here which works fine:

When being run locally with flask run and this .env:

DEBUG = True

When trying to add an item the log for Flask locally is simply: - - [18/Aug/2022 11:51:32] “POST /add HTTP/1.1” 200 -

The log for the Render DB is simply:

Aug 18 11:52:05 AM [1-1] user=[unknown],db=[unknown],app=[unknown],client=::1,LOG: connection received: host=::1 port=39886
Aug 18 11:52:05 AM [2-1] user=postgres,db=postgres,app=[unknown],client=::1,LOG: connection authenticated: identity=“postgres” method=md5 (/pgdata/dpg-cbr6hipa6gdikidj50m0-a/pg_hba.conf:10)
Aug 18 11:52:05 AM [3-1] user=postgres,db=postgres,app=[unknown],client=::1,LOG: connection authorized: user=postgres database=postgres application_name=psql SSL enabled (protocol=TLSv1.2, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256)
Aug 18 11:52:05 AM [4-1] user=postgres,db=postgres,app=psql,client=::1,LOG: disconnection: session time: 0:00:00.099 user=postgres database=postgres host=::1 port=39886

Expected behaviour would be that data is written to the DB as it is when I deploy to Render, but instead the add page is just reloaded and no data written.

Thanks for the additional detail.

It doesn’t appear the email your community uses is the same as the Render account owns the services you’re referring to, so I won’t be able to discuss specifics. However, I’m seeing no issues with the Render Postgres DB and external connections.

This is certainly pointing toward a local configuration issue. We’re not able to support your code directly as every app is different (in addition, I’m not overly familiar with Flask). However, some things you could try may be:

  • While I’m not seeing issues with external connections, double-check you’re able to connect to the Render Postgres instance directly from your local machine (copy the “PSQL Command” from the connections section).

  • The in the repo you shared only seems to pull the SQLALCHEMY_DATABASE_URI from the environment, and the other attributes appear to be hard coded, maybe they need to be updated to also pull from the env vars?

  • Ensure you’re using the “External Database URL” from the connections section for your SQLALCHEMY_DATABASE_URI in your local environment.

  • Does Flask behavior differ per mode? e.g. development vs production, if you’re using different env modes.

  • SQLALCHEMY_ECHO seems it could be useful for debugging, maybe you should enable it to see if SQLAlchemy is reporting anything.

As an aside, it’s usually best practice to have local environments use a local DB, to ensure you don’t accidentally connect to/affect production data. It’s fine if you’re just testing things out, you’d just need to be careful once your project is up and running.


That’s helpful, thank you. Yes my render is on my other email (do you mind removing the email from your post just in case it causes spam). I really appreciate the tips, I will work through and try these.

You cracked it. It was these parts of the config:




Which were causing this behaviour!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.