Postgres in docker - pq: SSL is not enabled on the server - postgresql

Progressing with setting up a local chainlink node following the docs. When I enter:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:1.1.0 local n
And after entering my key store password I am given an error / WARN:
2022-02-02T16:47:33.598Z [WARN] Postgres event broadcaster: reconnect attempt failed, trying again... pg/event_broadcaster.go:94 error=pq: SSL is not enabled on the server logger=EventBroadcaster
This then also leads to localhost:6688 returning nothing.
After googling this it seems it's an issue with SSL being enabled for postgres in docker, however I've tried many ways to fix but to no success. I can see my local postgres server has SSL enabled and tables have all been created. I am using WSL2 on Ubuntu to run the node with the Postrgres DB managed on Windows.

Just solved this same problem, modify your postgreSQL url to something like
postgres://username:password#localhost/db_name?sslmode=disable
Reference: SSL is not enabled on the server

Related

Postgres + Intellj: Fatal role can't connect to database

Try to connect to the database through Intellj for Postgres. I just keep getting the error message. Not sure if I can include any specific details, because this is connect through IntelliJ so there's not a lot of details I can tell. The progress is running with docker and ./gradlew sDS to kick off the running volume.
The specified database user/password combination is rejected: [28000] FATAL: role "username" does not exist.
I got it to resolved, I'm having another Postgres running on the computer. Just want to mention anyone who have the same trouble as me, make sure to check if your port is not running when you run this command. If after you shut down everything with docker but they'll a port still running then you need to track down and stop other Postgres that is currently running.
lsof -nP -iTCP -sTCP:LISTEN | grep "port #"

CHAINLINK NODE: How might I approach fixing "unable to lock ORM" errors?

I am not overly familiar with the process of setting up a chainlink node. I have done so today, but am running into an issue. On the very last step, when attempting to start the chainlink node I put the following into the command line:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink local n
When this runs the pulls all say "pull complete"
I am getting the following ORM errors:
2020-10-15T22:07:30Z [ERROR] unable to lock ORM: dial tcp
127.0.0.1:5432: connec t: connection refused logger/default.go:139
stacktrace=github.com/smartcontrac
tkit/chainlink/core/logger.Error
/usr/local/go/src/runtime/proc.go:203 2020-10-15T22:07:30Z [FATAL]
Unable to initialize ORM: dial tcp 127.0.0.1:5432:
connect: connection refused unable to open for gorm DB
I am not sure what might be the issue. Could someone point me in the direction I might start in the debug this issue?
[ERROR] unable to lock ORM is the default message given when the data is not able to be reached, and it also don't see another user with a lock. You can see the reason it can't connect to the ORM is because: dial tcp 127.0.0.1:5432: connec t: connection refused To fix, you can try a number of different things:
1. Try to access the postgress database using the parameters of the DATABASE_URL
If you can't get into the DB with the parameters of the DATABASE_URL there might be something wrong with that. You can see if you can connect by downloading the psql client. If on ubuntu you can use:
sudo apt-get update
sudo apt-get install postgresql-client
and then running something like psql -h IP_HERE -U USER_HERE and then entering your password
2. Add --network host for local databases
If you are running your node/database locally you'll have to add --network host to your chainlink docker command.
3. Try localhost, 172.17.0.1, or use a cloud DB if you're using a mac.
Docker is a little tricky when it comes to IPs. If you are running a local DB and you are trying to use 127.0.0.1, you may want to try localhost. On a mac, you'll run into issues since the docker gateway doesn't play nicely with macos, and easy work around is to get a database URL from a cloud database like on heroku, GCP, or AWS.
If none of these work for you, please add a comment and we can update this answer.
After reviewing Patrick's video, I noticed that that I was copying the Public IP, when in fact, the private IP from GCP is what you need you use in you command to run docker

why can't i connect to postgres on AWS EC2?

I'm hoping someone who has experienced this before can help me get this connection to AWS/EC2 -> Postgres working.
All the following is via terminal, on a Mac client.
The database in question - Postgres - is running remotely on this EC2 server, not, on my local Mac (nor is Postgres installed on my local Mac)
My understanding is that I need to be able to actually connect to the EC2 server and make an SSL "tunnel" connection -: from my PC to this same EC2 server -- so I can then, access the Postgres database
If my understanding there is wrong please let me know.
So, I have 2 terminal windows open. Terminal A, and Terminal B.
In Terminal A
(a) connecting to the EC2 server works fine. Here's the CLI command:
ssh -L 3307:127.0.0.1:3306 -i my.pem ubuntu#xx.yy.zzz.99
The CLI in Terminal A then shows me the Ubuntu/server prompt
Last login: Wed Oct 25 12:27:31 2017 from aaa222-444.xxxx.rrr.ff.net
ubuntu#ip-111-222-333-44:~$
then, I go to terminal B...
In Terminal B
(b) i try to make a connection to Postgres from local using the following command:
psql -h localhost -p 3307 -U postgres_uid postgres_databasename
THIS FAILS EVERY TIME.
I get this response in Terminal B:
psql: received invalid response to SSL negotiation: [
I am wondering, is there is a DIFFERENT SSL setup that is needed to make this DATABASE connection ? Or should it be that once I am logged into the AWS EC2 server (as noted above) I should be able to run psql commands (or use GUI clients like Navicat etc) ?
I'm at a loss and no one here knows how to fix this / set this up. it's probably something simple but that's fine, I just need to get connected :-)
Appreciate anyone's help with this thanks.
Use URI syntax in the -d option, and the SSL should take care of itself.
I use the following command to access cloud postgres instances (on bluemix, not ec2), give it a go...:
psql -d postgres://<user>:<password>#<host>:<port>/<dbname>

pgAdmin4: Unable to connect to Amazon EC2 via SSH Tunnel

I have Amazon EC2 instance running Ubuntu. I have installed and configured PostgreSQL.
Contents of the file /etc/postgresql/9.3/main/pg_hba.conf:
local all all md5
host all all 0.0.0.0/0 md5
Also in postgresql.conf
I have set listen_addresses='*'.
The test command below is successfully starting psql console.
psql -U postgres testdb
Now I am trying to connect pgAdmin4 from MacOS.
I have created a SSH tunnel with following command:
ssh -i ~/.ssh/test.pem -fN -L 5433:localhost:5432 ubuntu#mytestdomain.com
Now I have following details in pgAdmin:
When I save, I get this output:
Unable to connect to server: server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request.
What am I doing wrong ?
Here is the solution,
install pgadmin 4 into your system. and configure the below-added configurations. if the below configurations do not work then please check that DB user permissions on AWS. because of the restriction on IP level so it may not be able to access.

Connect to database in docker container on remote host with pgadmin3

I'm trying to connect to a database running in a docker container on a remote host. I configured SSH-Tunnel in pgadmin3 with ip of the host and identity file. On Settings tab I inserted 172.18.0.2 (the container IP) as host. It is not possible to connect. pgadmin turns grey for a while and presents me a beautiful error message:
SSH error: Error when starting up SSH session with error code -8 [Unable to exchange encryption keys]
Do I miss something? Is it possible to connect to the container?
When I upgraded pgAdmin 1.20.0 to 1.22.1, I started getting the same error. pgAdmin 4 doesn't have support for any SSH tunnel either. So, the only option you have right now is .. revert back to 1.20.0. Unfortunately, if you're on PG9.5 or better, pgAdmin 1.20.0 doesn't support it.
If you require access to a Postgres 9.5 database, you can manually create the SSH tunnel, and then connect using pgAdmin3 by setting the host to localhost. On Linux or Mac, you can use the following: ssh -L 5432:<pg-host>:5432 <jump-host-ip-or-dns>. It doesn't seem likely that pgAdmin3 will receive any updates with the direction pgAdmin4 is heading.