Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to PostgreSQL instance hosted in cloud foundry

I have created an postgresql instance from market place in my space who's instance name is : stack-uaa-postgresql

I want to connect to it from console so that i can execute sql queries .

I followed this document :

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-services.html

and executed this command :

cf create-service-key stack-uaa-postgresql postgresqlkey

and then validated it using :

cf service-key stack-uaa-postgresql postgresqlkey

and I got following response :

 {
 "dbname": "removed",
 "hostname": "removed",
 "password": "removed",
 "port": "33784",
 "ports": {
  "5432/tcp": "33784"
 },
 "uri": "removed",
 "username": "removed"
} 

I have removed values.

But when I am trying to do tunneling using ssh in my postgresql using below command I am getting exception :

> cf ssh -L 63306:<username>:<password>@<host internal ip>:33784
> stack-uaa-postgresql

FAILED App stack-uaa-postgresql not found

what is it that I am missing , is there alternate way to making connection with cloud foundry postgresql

like image 253
focode Avatar asked Dec 31 '25 18:12

focode


1 Answers

I know it’s confusing, but for tunneling you need to deploy an actual app to the space where your database is located and you are tunneling to that app via the cf command (I know it makes no sense, why you need an app there, but as far as I know there is no other way):

cf ssh -L localhost:<localport>:<remotehost-ip:<remoteport> <app-name> -N

Also don’t forget to call cf enable-ssh <app-name> (one time) for the app you will use for the tunnel.

like image 63
funfried Avatar answered Jan 03 '26 13:01

funfried



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!