How to Connect using Port Forwarding Database Postgrsql on Openshift 3 - postgresql

I Have a problem on Connect from Port Forwarding Database on Openshift :
Running Pods Postgresql :
I Try Connect to Container running the database to check process and psql command, then it works :
Next, I Try Port Forwarding for Try Connection from outside Openshift Cluster:
Then I Try Connect from Outside Cluster to connect Postgresql have Error: Connection Refuse
Im Using IP Based or Hostname / FQDN Not Working and Error Still Exist
And When I Try Check Firewall port it has been opened port 5432/TCP :
Anyone Can Help Me With This problem ?
Thanks
Note: Before I have Been Looking Documentation but Not Working Resolve the Problem
Source Documentation:
https://www.openshift.com/blog/openshift-connecting-database-using-port-forwarding
"psql: could not connect to server: Connection refused" Error when connecting to remote database

The oc port-forward command is forwarding from only your loopback interfaces.
If you are running your client on the same machine where the cluster is running, then use localhost as your "Host".
If you are running your client on a different machine, they you need more network redirection to get this to work. Please see this post for more information as well as work-arounds for your problem: Access OpenShift forwarded ports from remote host

Related

Not able to connect Oracle container database from SQL Developer

I am not able to connect the docker container using SQL developer. I used the docker desktop container internal ip ( ip a) and port number (docker port <container_name> ), but still getting the below error.
Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=nEnUfwk5Spaz8T7qS3vmCw==)
Here is my SQL Developer configuration:
The ip address and port aren't reachable from your host machine where SQL Developer is running.
See here where our Docker images are setup for you to simply connect via localhost:
https://hub.docker.com/r/gvenzl/oracle-xe

Can't connect to MongoDB on VPS

I'm trying to connect from MongoDB compass to my database which is on VPS. MongoDB itself is working on the VPS. As well I allow firewall to connect from my IP. But it's still doesn't allow me to go. Error - connect ECONNREFUSED "ipaddress:port"
I also tried to use SSH tunnel with the same IP and port and I'm getting confused which SSH username and SSH password I need to use?
I'm using Ubuntu 18.04 on my VPS.
I checked so many resources on how to connect but doesn't find any helpful. First the problem was with Firewall and allowance of ports and IP. But now i'm 100% sure that I allow it in firewall.
For SSH Hostname - I use my IP
SSH Tunnel port - I use port which I allow
GOAL: Any solution how I can connect my MongoDB which is on VPS to MongoDB Compass? I'm really clueless on how to get it.
EDIT1
This error I receive after I'm trying to connect with MongoDB Compass -
Error creating SSH Tunnel: (SSH) Channel open failure: Connection refused
When I change the port I receive this error - Error creating SSH Tunnel: connect EADDRINUSE

Docker container, running PostgreSQL not allowing php's pg_connect from another container

I have the following architecture:
A network with 3 containers:
container_db, running PostgreSQL
container_pg_admin, running a simple pgAdmin environment
container_php_dev, running the whole environment, needed for the application to function properly (nginx, php, angular for the frontend, etc.)
When I try to pg_connect() from container_php_dev to container_db the connection gets refused. This is the actual error message I get: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: No route to host↵ Is the server running on host "container_db" (172.18.0.4) and accepting↵ TCP/IP connections on port 5432?.
However, when I try to connect to container_db from container_pg_admin I face no problem achieving this (host is container_db and port is 5432). Even if I map port 5432 of container_db to 5555 on host, I'm able to connect to 127.0.0.1:5555 from DBeaver or other DB Manager (TeamSQL).
All containers were restarted a few times as well as docker itself. And as this is my development machine, the host PC was restarted as well.
What might be the problem, how to diagnose and possibly solve? Have any of you experienced such strange docker behaviour?
Try running the container_db in the hosted network using flag --network host

Is there any issue using the same postgresql database for two different servers?

I am using postgres database which is accessed by jboss and tomcat server.
My server accidentally restarted and then postgres service was not showing in the services list.
When I tried to open postgres local host server using pgadminIII it showed following error:
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
If you encounter this message, please check if the server you're trying to contact is actually running PostgreSQL on the given port. Test if you have network connectivity from your client to the server host using ping or equivalent tools. Is your network / VPN / SSH tunnel / firewall configured correctly?
For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. In order to access the server over the network, you need to enable listening on the address first.
For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use '*' to listen on all available IP addresses. For earlier servers (Version 7.3 or 7.4), you'll need to set the "tcpip_socket" parameter to 'true'.
You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. After changing this file, you need to restart the server process to make the setting effective.
If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. You probably have some low level network connectivity problems (e.g. firewall configuration). Please check this thoroughly before reporting a bug to the PostgreSQL community.
Does this problem arise due to accessing same DB by two different servers?
My server accidentally restarted and then postgres service was not
showing in the services list.
You can't connect because it's not running. You can have as many clients connecting to a PostgreSQL server as your hardware can support - there is no problem with that.
Restart your PostgreSQL service. If it won't, check the logs for why. If you don't know where your PostgreSQL logs are now is a good time to find out. I can't tell you how to restart the service because you haven't said what OS you are running or how you installed PG. Check your documentation.

OpenShift: How to connect to postgresql from my PC

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.
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