Is is possibile to use CF's postgres instance for user application?

Skip to first unread message

Apr 28, 2015, 5:37:33 AM4/28/15
to, Alvise Dorigo, Alvise Dorigo
I wonder if it is possible to use the deployed CF's postgres instance as backend database for my application.
I've tried to connect using the postgres command line psql, by I've received this error:

  psql -h localhost -p 5524
  psql: FATAL:  role "root" does not exist

Of course I've tried with other user candidate I presume could be: postgres, vcap, but I still receive the same error (with root string substituted by "postgres", "vcap").

The question is: How can I connect to that DB instance ? and, am I supposed to ?




Apr 28, 2015, 5:42:24 AM4/28/15

The best way to expose postgress as a service to user application. Why do u want to use specifally postgres instance of cf to user application

You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit

To unsubscribe from this group and stop receiving emails from it, send an email to

Alvise Dorigo

Apr 28, 2015, 7:30:14 AM4/28/15
Hi Narendra,
I was just wondering if that DB instance is there only for the CF's functioning, or if it could be used as a service. 
Your answer suggests that it is not supposed to be used as a service.



You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit




Apr 28, 2015, 8:13:48 AM4/28/15

We can expose postgres as a service but that will be a different instance and we should not be used cf instance for the user application. Postgress is available as a service in cf-contib service you can check the latest available repo on cloudfoundry github repositories.

Alvise Dorigo

Apr 28, 2015, 9:15:27 AM4/28/15


Apr 28, 2015, 9:16:37 AM4/28/15

Pravin Mishra

Apr 28, 2015, 12:06:07 PM4/28/15

Coming to your question first. Yes, you can connect and access the CF PostgreSQL database. Below are the details steps to access CF PostgreSQL database (know as CC DB [cloud controller database]).

1. Ensure that you are targeting the correct environment and have logged in:
$ bosh target <your_ip_address>
$ bosh login
# admin/admin is probably your password

2. ssh to the PostgreSQL database
$ bosh ssh

you should see something like the following:

1. ha_proxy_z1/0
2. nats_z2/0
3. nfs_z1/0
4. postgres_z1/0
5. uaa_z1/0
6. login_z1/0
7. api_z1/0
8. clock_global/0
9. api_worker_z1/0
10. etcd_leader_z1/0
11. etcd_z1/0
12. hm9000_z1/0
13. runner_z1/0
14. runner_z1/1
15. runner_z2/0
16. runner_z2/1
17. loggregator_z1/0
18. loggregator_z2/0
19. loggregator_trafficcontroller_z1/0
20. loggregator_trafficcontroller_z2/0
21. router_z1/0
Choose an instance: 

Choose the instance that matches your postgres database: 4. postgres_z1/0

You will be prompted with:

Enter password (use it to sudo on remote host): 
enter a password and this will be set as your sudo password for root access

3. Where is the psql command line binary?

To find out where the binary is located - along with the host and port parameters (which you will need...) try:

$ ps -ef | grep postgres
You should see a line like:

vcap      1729     1  0 Apr02 ?        00:00:02 /var/vcap/data/packages/postgres/5.1/bin/postgres -D /var/vcap/store/postgres -h -p 5524

So the binary is located at:


the host is and the port is 5524

4. What user should I connect as?

The root user does not exist, you will need to use

invoke psql:

cd /var/vcap/data/packages/postgres/5.1/bin/
./psql -h -p 5524 ccdb -U ccadmin

this will connect to the ccdb schema with the user ccadmin

Note that it runs on a non-standard port

5. Some nice commands
\l             List all databases
\c <dbname>    Connect to new database.
\dt            To view list of relations/tables
\d <tablename> Describe the details of given table.
\h             Get a help on syntax of SQL commands
\?             Lists all psql slash commands.
\set           System variables list.
\q             Quit psql 

P.S.: It's not recommended to use ccdb as a service.

Enabling a PostgreSQL service is pretty straight forward. You can follow this README steps. 

Best Regards,
Pravin Mishra

To unsubscribe from this group and stop receiving emails from it, send an email to


   Pravin Mishra
   Senior Software Engineer
   Skype: pravinmishra88
   Mob. +91-9555071486

Reply all
Reply to author
0 new messages