21

I have an openshift app, and I just installed a postgresql DB on the same cartridge.

I have the postgresql DB installed but now I want to connect to the DB from my PC so I can start creating new tables.

Using port forwarding I found my IP for the postgresql db to be

127.3.146.2:5432

under my webaccount I see my Database: txxx User: admixxx Password: xxxx

Then Using RazorSQl I try to setup a new connection

keeps coming as user password incorrect.

If I try and use the local IP to connect such as the 127.0.0.1 then I can connect fine.

How can I resolve this issue, all I am trying to do is connect to this DB so that I can create new tables.

1
  • Please can you explain how you did this Mar 2, 2015 at 21:09

1 Answer 1

32

As shown below, after running the "rhc port-forward $appname" command, you would need to connect to the ip address of 127.0.0.1 and port that shows up next to it to connect to the service you want to reach, such as postgresql. In the below example, i would connect to 127.0.0.1, port 5432. If you already have something running locally on the postgresql port, it will select another port and display it in the table. But the connection will be forwarded to your openshift gear and postgresql on your gear.

Corey-Red-Hat:~ cdaley$ rhc port-forward rt2
Checking available ports ... done
Forwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service    Local               OpenShift
---------- -------------- ---- ---------------
httpd      127.0.0.1:8080  =>  127.7.74.1:8080
postgresql 127.0.0.1:5432  =>  127.7.74.2:5432

Press CTRL-C to terminate port forwarding

You can refer to the OpenShift Developer Portal for more information about using the PostgreSQL cartridge here: https://developers.openshift.com/en/databases-postgresql.html

3
  • 1
    Okay Got it that makes sense now. So that wasnt clear. Jan 7, 2014 at 17:00
  • Sorry, one other question..What IP address should I use to connect to postgresql from my cloud App. I have two apps one on Openssh under the same cartridge, and one on a different cloud? Do I need to use the Openssh IP instead of the local one? Jan 7, 2014 at 17:12
  • 2
    You need to use your OPENSHIFT_POSTGRESQL_DB_HOST environment variable, along with the associated port and user/pass. You can't connect to it from another cloud provider without a port forward. Remember to mark the answer as correct if it was answered for you.
    – user2879327
    Jan 8, 2014 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.