Tuesday, February 11, 2014

PG::ObjectInUse: ERROR: source database "template1" is being accessed by other users

PG::ObjectInUse: ERROR:  source database "template1" is being accessed by other users
DETAIL:  There are 1 other session(s) using the database.

Database template1 exists only to use structure to create another empty database. You should never login to template1, otherwise you will have problems for login or create database.

Most likely easiest solution for you is to restart PostgreSQL server process, and logon again. 

For restart PostgreSQL server use this command:
sudo service postgresql restart
If restarting is not working then you can use another template database: template0.

For this log in with username and password in postgresql with this command:
sudo -u postgres psql template1
          Enter password if you used password for user "postgres"

Then change template with database_name 

By default, database create for template1 with this statement and this statement:
CREATE DATABASE database_name;
is equivalent to:
CREATE DATABASE database_name TEMPLATE template1;
If template1 is not available or corrupted, you can use template0 as last resort:
CREATE DATABASE database_name TEMPLATE template0;
You can read more about template databases here.



  1. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.
    Best CRM System

  2. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

    IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

    corporate training in chennai corporate training in chennai

    corporate training companies in india corporate training companies in india

    corporate training companies in chennai corporate training companies in chennai

    I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai