How to setup Datomic with Heroku Postgresql? - clojure

I have trouble setting up Datomic with Heroku Postgres. First of all I have this successfully installed
[com.datomic/datomic-pro "0.9.5206" :exclusions [joda-time]]
My sql-transactor.properties file looks like this:
protocol=sql
host=localhost
port=4334
license-key=<MY_LICENSE_KEY>
sql-url=jdbc:postgresql://ec2-54-204-3-200.compute-1.amazonaws.com:5432/<MY_HEROKU_DB_NAME>
sql-user=<MY_USER>
sql-password=<MY_PASS>
sql-driver-params=ssl=true;sslfactory=org.postgresql.ssl.NonValidatingFactory
When I try to run transactor from downloaded datomic-pro folder as:
bin/transactor /path/to/folder/sql-transactor.properties
It gives following output:
Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
Starting datomic:sql://<DB-NAME>?jdbc:postgresql://ec2-54-204-3-200.compute-1.amazonaws.com:5432/<MY_HEROKU_DB_NAME>?user=<MY_USER>&password=<MY_PASS>&ssl=true;sslfactory=org.postgresql.ssl.NonValidatingFactory, you may need to change the user and password parameters to work with your jdbc driver ...
System started datomic:sql://<DB-NAME>?jdbc:postgresql://ec2-54-204-3-200.compute-1.amazonaws.com:5432/<MY_HEROKU_DB_NAME>?user=<MY_USER>&password=<MY_PASS>&ssl=true;sslfactory=org.postgresql.ssl.NonValidatingFactory, you may need to change the user and password parameters to work with your jdbc driver
NOTE: The <DB-NAME> in the output is literally <DB-NAME>. It's not my placeholder. I think this might be a mistake.
Now when I try in clojure:
(def uri "datomic:sql://<MY_HEROKU_DB_NAME>?jdbc:postgresql://localhost:5432/<MY_HEROKU_DB_NAME>")
(def conn (datomic.api/connect uri))
It gives error:
java.net.ConnectException: Connection refused
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
clojure.lang.Compiler$CompilerException: java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections., compiling:(server.clj:40:11)
Anybody any ideas?
EDIT: I forgot to mention that I already did steps from http://docs.datomic.com/storage.html about bin/sql/postgres-table script

Related

connection to server at "localhost" (127.0.0.1), port 5432 failed

I am facing this error "OperationalError at /results/
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?" when I try to run a django application that I just deployed in railway.app.
What is the problem and how can I fix?
When I run the application locally it works well, it is my first time deploying a django application to production and I have no idea how to solve that issue, your help is greatly appreciated.
I just realized that the error is due to not using railway's database. Apparently it was running localhost and my postgres' port, created a postgres database in railway and connected to the deployed django app and it is now working well. Thank you #Laurenz Albe for reminding me that.

How to Access Remote PostgreSQL Database Server Through VPN

I'm currently working with my office server, when i want to connect to the server, i have to use their VPN. I have installed PostgreSQL database in their server and have succesfully migrate data to database from Django project. But, when i want to remote access from HeidiSQL, it always gives me Connection Timed Out Error eventhough i have already connected to their VPN.
I've tried to this code below
/var/lib/pgsql/14/data/pg_hba.conf
host all all 0.0.0.0/0 md5
host all all ::/0 md5
/var/lib/pgsql/14/data/postgresql.conf
listen_addresses = '*'
i have tried to refresh everytime i change files and see if i'm in the correct port but it still gives me Connection Timed Out Error
this is the full error message
could not connect to server: Connection Timed out (0x0000274C/10060). Is the server running on host "xxx.xxx.xxx.xxx" and accepting TCP/IP connections on port 5432 ?
NOTES
OS : CentOS 8
DB : PostgreSQL 14

How do I connect my Django App to Postgres Databse?

How do I connect my Django App to Postgres Databse?
Whenever I run python manage.py makemigrations after the changes, then I get this kind of error. How can I fix it?
Got an error checking a consistent migration history performed for database connection 'default': connection to server
at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections?
warnings.warn(
No changes detected
Seems like your postgres server is not running. I would suggest you to ensure that postgres server is running and you are able to connect to it.
You can use your terminal or any DB tool like PgAdmin, DBeaver, Tableplus etc.
After you are able to connect to your database through any of the above mentioned ways. Django db connection should not be a problem.
You can take help from
https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html
https://www.enterprisedb.com/postgres-tutorials/connecting-postgresql-using-psql-and-pgadmin

Database connection Error while hosting site on heroku

So I was trying to host my first Django app on heroku.
Took help form some Youtube channels. I used postgresql as my database. Now when I tried hosting my app on heroku the following error is showing up:
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?```
**This is the error showing**
run postgres -D /usr/local/var/postgres The result of this should be:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 379) running in data directory
"/usr/local/var/postgres"?
Then type kill -9 PID in HINT
Let me know if this works for you?

Chef Server Installation error

I am a newbie to chef. I am trying to install chef server on an ec2 centos instance.
I am following this link to install the chef server.
But I am getting error at step 8 of installation.
[root#ip-10-105-203-174 ~]# knife configure -i
/usr/lib/ruby/gems/1.8/gems/ohai-7.0.4/lib/ohai/loader.rb:188: warning: character class has `[' without escape
/usr/lib/ruby/gems/1.8/gems/ohai-7.0.4/lib/ohai/loader.rb:188: warning: regexp has `]' without escape
Overwrite /root/.chef/knife.rb? (Y/N)Y
Please enter the chef server URL: [https://ip-10-105-23-174:443] https://10.105.23.174
Please enter a name for the new user: [root]
Please enter the existing admin name: [admin]
Please enter the location of the existing admin's private key: [/etc/chef-server/admin.pem]
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] /root/.chef/chef-server/chef-validator.pem
Please enter the path to a chef repository (or leave blank):
Creating initial API user...
Please enter a password for the new user:
ERROR: Connection refused connecting to https://10.105.203.174/users, retry 1/5
ERROR: Connection refused connecting to https://10.105.203.174/users, retry 2/5
ERROR: Connection refused connecting to https://10.105.203.174/users, retry 3/5
ERROR: Connection refused connecting to https://10.105.203.174/users, retry 4/5
ERROR: Connection refused connecting to https://10.105.203.174/users, retry 5/5
ERROR: Network Error: Connection refused - Connection refused connecting to https://10.105.23.174/users, giving up
Check your knife configuration and network settings
Is this the right tutorial. Please help me resolving the issue.
You seem to be doing the right thing for chef, but it looks like a fundamental networking issue. If I understand properly, you are logged into the chef server and trying to set up knife on the same box to talk contact itself. Is Chef server actually running? Use 'netstat -an' and verify that something is waiting on the :443 port. Can you use a browser from another host to contact it? You could also consider installing "knife" on another machine and running the same thing.
Are you providing a valid chef-server url. At first look it looks like you are giving the workstation ip address.