I'm trying to integrate my Keycloak server with Postgres, and ran into an odd problem. When starting my keycloak server with the provided command on Ubuntu:
./kc.sh start-dev --http-port ${PORT} --db-url=jdbc:postgres://myurl.com/database --db=postgres --db-schema auth --db-username postgres --db-password password
I get the following error:
[org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread: keycloak-default) HHH000342: Could not obtain connection to query metadata: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
But of course, shown above, my database isn't on localhost, and I set the --db-url option accordingly. This makes me think keycloak is ignoring --db-url, as localhost:5432 is the default value for a Postgres connection.
Does anyone know why this might be happening?
EDIT: Running Keycloak version 19.0.1
Related
I get this error message (see below) and do not know what to do about it.
Error message:
"psql: error: 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? "
I am using Windows 10 (64bit) and have tried the same thing on Kali and Ubuntu and still was not able to use postgresql.
Does anyone have a suggestion what do to? However, please use "language" that I can understand or at least look up simply because I am new to programming (in general). Thank you
P. S. I tried various different things such as using pgAdmin to change ports but cannot solve a problem. I do not know if this is important but I istalled postgresql via Binaries because regular Installer was giving an error message telling me that comspec does not point to cmd.exe even though it actually did...
If you
properly set up your db (installation and initialization using initdb), and if you
have your data directory containing your postgresql.conf and pg_hba.conf among other things, and you
properly started the postgresql service,
then I can assume your problem is in the connection string.
Try to include the superusername and/or db name, your error maybe due to psql connecting to user localhost which does not exist inside your db.
Try to run psql with -U and -d options:
psql -U postgres -d postgres
I need ssl connection between postgresql (patroni cluster) and Haproxy but I didnt find any related docs. Is it possible to configure haproxy via ssl without using pgbouncer or pgpool tools.
I can connect directly to the database server with ssl configuration
but I can't connect by using Haproxy,
-bash-4.2$ psql -d "host=x.x.x.x port=7010 dbname=postgres user=test"
psql: error: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
-bash-4.2$
there is no log record on postgresql.
Thanks.
I am new to PostgreSQL, and I want to use it on my personal laptop for personal projects. I use SQL Server and SQL Server Management Studio at work, coding-wise I'm ok but I need some help with setting up the localhost on my laptop.
So I downloaded PostgreSQL and installed it along with pgAdmin that came with the package.
During installation, it asked me to create a PostgreSQL superuser password, which I did.
Then I tried creating a new server using pgAdmin as follows:
General Tab:
Name: localhost
Server Group: Servers
Connect Now?: check
Connection Tab:
Host name/address: localhost Port: 5432
Maintenance database: postgres
Username: postgres
Password: [blank]
But when I click save I'm getting an error message:
Unable to connect to server: 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?
Also tried replacing the password field with the Superuser password, getting the same error message.
Would greatly appreciate it if anyone offers any insights into this problem, I might just be a noob when it comes to server setups...
Thanks,
Mike
Update:
I believe there's a service I need to start as suggested by #Scott Moniz. I went into services.msc, tried to start the service postgresql-x64-10 - PostgreSQL Servier 10, and I got this error message:
"The postgresql-x64-10 - PostgreSQL Server 10 service on Local
Computer started and then stopped. Some services stop automatically if
they are not in use by other services or programs".
I then tried editing the property of the service, by changing the Log on as option to Local System Account and tried starting the service again, still got the same error message.
I'm using Windows 10 Home edition, it this helps to resolve the issues in anyway
Thanks,
Mike
Are you sure the database service is running and listening?
CLick Start>Run> type services.msc
Look for a postgresql service - if it does not say started right click it and click Start.
Alternatively you can restart your computer and the service should start if it is set to 'Automatic'
New to web development. Trying to connect and register new server for pgAdminIII. (using cloud 9 ide)..
I get this error when viewing in the browser..
_PG::CONNECTION BAD _
could not connect to server: Connection refused Is the server running on
"localhost" (::1) and accepting TCP/IP connections on port 5432?
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
PS. trying to access via new user "ubuntu" SUPERUSER created..
How can I fix this?
PPS. On cloud 9's community forum, an employee says..
"Only ports 8080, 8081 and 8082 are open for workspaces so if you want to access the DB externally you'll need to run it on one of these ports. Make sure you can access it with curl from a local terminal and ensure it's listening on 0.0.0.0 not 127.0.0.1, as the latter only allows local connections."
Lastly, their ide comes with postgres installed, all I needed to do, was set it up..
How do I use the above info while trying to register the new server in order to use the gui?
Let me know if I need to include anything else.
Thanks.
You should enable postgresql service by performing sudo service postgresql start.
After enabling, you can access the console using sudo sudo -u postgres psql and CREATE ROLE ubuntu LOGIN REPLICATION CREATEDB CREATEROLE SUPERUSER; to allow Rails take advantage of your database.
Rails also complains about template read error after creating ubuntu role.
To fix the template error, read up on this.
You should get PostgreSQL server up and running in no time. Happy coding!
Edit:
You should only use localhost for local and system resources (i.e. psql, etc.) while 0.0.0.0 is for everything else like running Rails or Apache server.
I just installed bugzilla-4.4.1 on version 6.4 of Scientific Linux, and I'm having problems connecting to the database (Pg version 8.4).
When I try to fetch the main page (index.cgi), I get the following message:
Software error:
Can't connect to the database.
Error: could not connect to server: Permission denied
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Is your database installed and up and running?
Do you have the correct username and password selected in localconfig?
For help, please send mail to the webmaster (root#localhost), giving this error message and the time and date of the error.
Postgres's pg_hba.conf.conf is configured for md5 auth on localhost:
host all all 127.0.0.1/32 md5
and I can connect to the bugs user in the database using psql:
psql -h 127.0.0.1 -U bugs
Running checksetup.pl seems to confirm that the database is set up and configured properly:
... snip ...
Reading ./localconfig...
Checking for DBD-Pg (v2.7.0) ok: found v2.15.1
Checking for PostgreSQL (v8.03.0000) ok: found v08.04.1800
Removing existing compiled templates...
Precompiling templates...done.
Fixing file permissions...
Now that you have installed Bugzilla, you should visit the 'Parameters'
page (linked in the footer of the Administrator account) to ensure it
is set up as you wish - this includes setting the 'urlbase' option to
the correct URL.
checksetup.pl complete.
[root#PAHRALBLNX001 bugzilla]#
and the testserver.pl script indicates that the server is set up properly:
[root#PAHRALBLNX001 bugzilla]# ./testserver.pl http://127.0.0.1/
TEST-OK Webserver is running under group id in $webservergroup.
TEST-OK Got padlock picture.
TEST-OK Webserver is executing CGIs via mod_cgi.
TEST-OK Webserver is preventing fetch of http://127.0.0.1/localconfig.
I've also verified that the bugs username and password in localconfig matches the setup in Postgres.
The one thing that seems odd however, is that when I look at localhost with Wireshark, I don't see any attempts to connect to the PostgreSQL server while accessing the bugzilla main page. However, if I connect to the PostgreSQL server using psql, I do see the connection in Wireshark.
Edit
I also discovered that bugzilla wouldn't send email. This turned out to be a selinux problem as pointed out by Daniel Vérité. I changed httpd_can_sendmail and httpd_can_network_connect to true, and now it works.
Based on the error message:
Error: could not connect to server: Permission denied
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Permission denied when trying to connect to an IP address means it's denied by the local security policy.
The web server must be enabled to connect to databases with this command:
setsebool -P httpd_can_network_connect_db 1
and if it's not sufficient:
setsebool -P httpd_can_network_connect 1
See http://wiki.centos.org/TipsAndTricks/SelinuxBooleans for more