How to change Postgresql database from Read-only to Writable

Solution 1:

Since SELECT pg_is_in_recovery() is true you're connected to a read-only replica server in hot_standby mode. The replica configuration is in recovery.conf.

You can't make it read/write except by promoting it to a master, at which point it will stop getting new changes from the old master server. See the PostgreSQL documentation on replication.

First step is to check whether there is a 'recovery.conf' file in the data directory. If it exists, if you are sure you are on master (not slave) server, rename that file to 'recover.conf.backup'. Then, re-start postgresql server. It should allow you to write new records now.