Postgres and Atlassian Jira: driver issue - postgresql

I am trying to setup a server with centOS 32 bit to install Atlassian Jira on it.
I followed the official Atlassian installation guide at https://confluence.atlassian.com/display/JIRA/Installing+JIRA
Now I am running the Setup Wizard and I need to configure a PostgreSQL database. On my centOS, I installed version 8.4.20 via yum.
However, I am having a hard time setting Jira. Postgres is running and I can login via Linux console, but when I test the connection to the database, I get the following error:
Error connecting to database
Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Connection refused
Also, this error appears when I type the full public IP address. If I insert localhost, I get this:
Error connecting to database
FATAL: Ident authentication failed for user "jiradbuser"
If I insert
http://<public ip>
I get the following:
Error connecting to database
No suitable driver found for jdbc:postgresql://http://<public ip>:5432/jiradb
However, I put my jdbc driver into /opt/atlassian/jira/lib and its name is postgresql-8.4-703.jdbc4.jar. Postgresql version is 8.4.20.
Where am I doing wrong?

Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
By default, PostgreSQL listens only on the local loopback interface, so connecting to the public IP won't work. If you're connecting from localhost you don't need to anyway, just use localhost.
FATAL: Ident authentication failed for user "jiradbuser"
This is good, it shows that you're connecting to PostgreSQL successfully, then getting an authentication error when trying to log in.
Your PostgreSQL server install defaulted to ident authentication for TCP/IP connections, but the JIRA application isn't running under a unix user named "jiradbuser" so the connection is rejected. Change pg_hba.conf to use md5 instead of ident and set a password for the user. See the client authentication chapter in the docs, particularly, pg_hba.conf.
No suitable driver found for jdbc:postgresql://http://:5432/jiradb
I have no idea where you got the idea that that URL would work...
You want something like:
jdbc:postgresql://localhost:5432/jiradb

I had the same problem. I could solve it setting up the postgres driver .jar from maven repository to \target\jira\webapp\WEB-INF\lib\

Pretty late to the question here but thought I'd add a couple bits to help out the future, going backwards:
No suitable driver found for jdbc
A while ago Atlassian didn't distribute the PostGreSQL JDBC driver file with the JIRA releases. They have been doing this for a while now (I'd say since mid 2013) - regardless, the driver file belongs in the <jira-base>/lib directory unless you are doing a WAR install, in which case you shouldn't, and just put the driver file in the lib directory anyway
FATAL: Ident authentication failed for user "jiradbuser"
1. Listen on a socket if you need to - The best approach to this is to look at your JDBC driver URL - if it has an IP/hostname other than 127.x.x.x or 'localhost' you need to modify PostGreSQL to listen to a TCP port by modifying your postgresql.conf file to enable listening on ports. Just find the file, back it up, then open it and search for localhost, read the file comments and make the correct change. If you find yourself looking around in multiple locations in the file or changing more than a single word you are trying too hard - restore your backup and try again. Just remember to *stop* and *start* your postgres db cluster when you are done
2. enable the correct login METHOD in pg_hba.conf (same directory as the postgresql.conf file - on unix typically under /etc/postgresql/<version>/main/.) - this is difficult to writeup in brief but I'll try
1. backup the pg_hba.conf file - I ain't foolin, this is something you'll be happy with later - back the sucker up
2. edit the file
3. go to the bottom of the file - look for the last line like "# TYPE DATABASE USER ADDRESS METHOD"
4. comment out every line under this 'table heading' line
- the reason to do this is that the package maintainers often fall back to commenting here and so you'll have 2 commented out lines and then one line that isn't commented out - and you'll never notice it - it's easiest to just start off with commenting out the whole block of stuff so there isn't a single uncommented line in the file
- add a two lines for the postgres user to connect local and to a db socket unless your corporate security does not allow - something like this:
local all postgres 127.0.0.1/32 peer
host all postgres 127.0.0.1/32 trust
- add a line for your jiradbuser to connect to the newly created database via sockets with md5 encryption. md5 isn't the best - there are other options to google - if you use md5, it'd look something like this:
host jiraversiondb jiradbuser 127.0.0.1/32 md5
Then save the file, restart postgres cluster (with a stop and start, not with the 'restart' option), and test connecting from the command line.
How to test connections from the command line
If you are logged into a unix system with the postgres tools installed you should be able to mimic the connection attempt which the JIRA server will try to connect to the database. If you cannot connect to the new postgresql db from the command line it's a REAL GOOD chance that JIRA won't be able to either. Plus you'll get better error messages. So to do this just bring up a shell and enter (replacing variables where appropriate - things within the '<' and '>' characters) - all the values for these are in your head and the postgresql.conf file:
psql --port <port - default is 5434> --username=<db user name> --password --dbname=<database name>
Once you can connect from the command line it's a good bet JIRA will as well - no promises, but you'll be on sound footing.
...ahhh....now, that'll hopefully help someone...

Related

Cannot connect AppSmith to local PostgreSQL server

Problem
In general, there have been a ton of issues in connecting a remote service to a PostgreSQL database. The documentation for most services doesn't really have documentation for this since the task of connecting to a PostgreSQL database requires the Admin to modify both the postgresql.conf and pg_hba.conf files.
The current scenario is giving AppSmith remote access to the given server.
PostgreSQL needs to allow the following IP addresses at the pg_hba.conf: 18.223.74.85 and 3.131.104.27
Research SSL Connections and if one would be required in this case
Success Criteria:
Appsmith is able to connect to given database
Appsmith is able to read/write data to given database
Resolution Research
Allowing the above IP addresses to connect to the PostgreSQL database in the pg_hba.conf file and changing the postgresql.conf file to allow remote connections using listening_addresses = '*' did not resolve the issue. Appsmith is unable to connect to the database.
SSL Connection: SSL stands for Secure Sockets Layer and, in short, it's the standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.
SSL proved to be a dead-end for this issue with no resolution.
In order to create an SSL connection, the following steps must be followed (PostgreSQL SSL documentation: https://www.postgresql.org/docs/9.1/ssl-tcp.html):
OpenSSL needs to be installed on the host server (https://fedingo.com/how-to-install-openssl-in-ubuntu/). Determined that OpenSSL is already installed on the host server using openssl version -a.
Following the above steps from the postgresql documentation does not produce the desired result.
Following steps from https://www.cyberciti.biz/faq/postgresql-remote-access-or-connection/ does not work either.
Error in all cases on Appsmith: Failed to initialize pool: The connection attempt failed
Next-steps
Consult with the Stackoverflow community to see if anyone else is having a similar issue.
Similar issues have been found, but Appsmith documentation and the Stackoverflow community did not have the information needed to fulfill this issue. I will post the full case to the community.
I resolved this problem using ngrok to make a tcp tunnel on your localhost.
Donwload and conifg ngrok and create a new tunnel on terminal, just run ngrok tcp 5432 at terminal
After this, get the host/port and insert at Appsmith PostgreSQL Connection.
make sure your username/password is correct.
Image from host/port create on ngrok
Image to how config this host/port on Appsmith

Unable to connect postgres DB remotely

Every time, when I try to connect to remote Postgres DB, I receive error:
no pg_hba.conf entry for host "159.224.92.121", user "xpkzxqrkisdrjd", database "d92na0gp4bdq4", SSL off
I googled it and found that two config files should be updated.
Should append:
pg_hba.conf
host all all 0.0.0.0/0 md5
postgresql.conf
listen_addresses = '*'
I did it, but error still occurs, when I try to connect to remote DB.
Local DB work fine.
Any ideas?
UPDATE
Maybe it will be useful. I have installed postgres using homebrew.
For restarting postgres server I use:
brew services postgres restart
Two items to help you on the way:
pg_hba.conf is processed from top to bottom, so if the incoming connection matches an earlier line, that entry will be used.
Set log_connections = on in postgresql.conf and reload. Then, after a connection attempt has failed, look into the log file for the reason. Recent PostgreSQL versions will also tell you which pg_hba.conf line was used.
So, I continued to google this issue and finally found the answer. You should use SSL option.
Please, check this link:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/205996299/comments/206373089

Openbravo - Connecting pgadmin with postgresql database in Ubuntu

I have installed Openbravo ERP 3.0 in Ubuntu 12.04(LTS). After completed the installation I tried to connect with postgresql database using pgadmin 9.1. I gave all the details as mentioned in this link: http://wiki.openbravo.com/wiki/Installation/Appliance/Openbravo.
Also I have changed the config file settings like listen_addresses="*". I got this error after I click "Ok" button
Could anyone give suggestion to fix this error? Thanks in advance.
Actually the problem comes because of not mentioning the local cluster or data area for PostgreSQL. To do this after installing Openbravo, need to give this command in terminal
psql -d openbravo -U tad -h localhost -p 5932
Finally give the PostgreSQL configuration details as mentioned in this link
It works fine now...
To be able to reach the server remotely you have to add the following line into the file: /var/lib/pgsql/data/postgresql.conf:
listen_addresses = '*'
PostgreSQL, by default, refuses all connections it receives from any remote address. You have to relax these rules by adding this line to /var/lib/pgsql/data/pg_hba.conf:
host all all 0.0.0.0/0 md5
This is an access control rule that lets anyone login from any address if a valid password is provided (the md5 keyword). You can use your network/mask instead of 0.0.0.0/0 to only allow access from certain IP addresses.
When you have applied these modifications to your configuration files, you will need to restart the PostgreSQL server.
/etc/init.d/postgresql start
Now, you will be able to login to your server remotely

PostgreSQL: Access to database denied

I'm using PostgreSQL 9.1 on an Ubuntu 12.04 server. The database instance seems to run fine in general and when I try and connect from pgAdmin III via localhost on the server machine itself, there is no problem.
Whenever I try to use the LAN address 192.168.1.16 from the server, I get the error "Access to database denied."
From what I gather, the common culprit in these sorts of situations seems to be the configuration described in the pg_hba.conf file, which currently contains the following:
host all all 192.168.0.1/32 md5
As far as I understand, the instance should accept all users. Is there anything I'm missing here?
Note that you are trying to connect from 192.168.1.16, however, your pg_hba.conf is allowing only 192.168.0.1 (that's what the /32 means).
Check https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#IPv4_CIDR_blocks to learn more about CIDR notation.
If you want to allow 192.168.1.16 only you can add the following line at your pg_hba.conf:
host all all 192.168.0.16/32 md5
Then, run pg_ctl reload to apply the change made above.
This answer is assuming that you have verified the listen_address parameter in your postgresql.conf file and it's binding the correct IP values.

pgadmin gives me the error: no password supplied

I've installed postgresql 9.2 on linux (kubuntu) and the last version of pgadmin3, but when I connect them I have this error:
An error has occurred:
Error connecting to the server: fe_sendauth: no password supplied
What can I do?
I have also configured tomcat for my web application in java. In fact, postgresql was working before trying my application.
Change the password for role postgres:
sudo -u postgres psql postgres
alter user postgres with password 'postgres';
Try connect using "postgres" for both username and password.
Refer to: How to change PostgreSQL user password
Whether a password is required depends on your settings in pg_hba.conf. And there are different ways you can connect - different settings in pg_hba.conf may apply.
I quote the help shipped with pgAdmin 3 for the "Host" field in the connection ("server") settings:
The host is the IP address of the machine to contact, or the fully
qualified domain name. On Unix based systems, the address field may be
left blank to use the default PostgreSQL Unix Domain Socket on the
local machine, or be set to an alternate path containing a PostgreSQL
socket. If a path is entered, it must begin with a “/”. The port
number may also be specified.
If you connect via Unix socket the rules for "local" apply.
Whereas when connecting via TCP/IP "host" (or "hostssl") rules applies.
If you have a line like this at the top your pg_hba.conf file:
local all all peer
or:
local all all ident
.. then you can connect locally without password if your system user is "postgres" and your database user is "postgres", too.
I realize this is question is years old, but I ran into this same problem today and have a solution that uses trust in a limited but useful way.
As in many development shops, when the devs need a QA postgres password, they just yell it, message it, email it, write it on their foreheads, etc. And I'm like, "This is really bad. I need to figure out a way to use PKI here." We also use pgAdmin3.
First, add a line like this to your pg_hba.conf, where dev represents the user for the developers in your shop:
host all dev 127.0.0.1/32 trust
Drop the developers' public key in their authorized_keys folder on the database server. Now have them ssh into the server with the -L flag with a command similar to the following:
ssh -i ~/.ssh/id_rsa -L5432:127.0.0.1:5432 -vvv 101.102.103.104
This allows one to use the postgres port as if it were localhost. Of course, replace the key, server and make sure to map to an open port locally (if you have a local postgres running, it's probably bound to 5432). I use a pretty verbose flag so I can easily troubleshoot any ssh issues.
Open another terminal and issue this command:
psql -h 127.0.0.1 -U dev -p 5432
You should have access to the database and never be prompted for a password, which I think is great because otherwise, the devs will just waive the password around with little regard to security, passing it out like Halloween candy.
As of now, PgAdmin3 will still prompt you for a password, even though -- plain as day -- you do not need it. But other postgres GUIs will not. Try Postico. It's in beta but works great.
I hope this answer helps anyone like me who would rather use PKI for postgres auth rather than sharing passwords willy-nilly.
Met this problem recently.
If you're using PostgreSQL on local machine, and psql works well without logging needed, try pgadmin3's menu File - Add Server - Properties tab, fill in Name field for this connection, leave Host field and Password field empty, and click ok.
from pgadmin docs
On Unix based systems, the address field may be left blank to use the
default PostgreSQL Unix Domain Socket on the local machine, or be set
to an alternate path containing a PostgreSQL socket. If a path is
entered, it must begin with a “/”.
Worked on Debian testing (pgadmin3 1.22, PostgreSQL 11), without touching pg_hba.conf.
For me, I run pg_ctl -D /usr/local/var/postgres start, start the server, then everything is OK, it will pop out the connection host port.