tigase-server icon indicating copy to clipboard operation
tigase-server copied to clipboard

Connection to localhost:5432 refused

Open kosaa opened this issue 2 years ago • 3 comments

I have followed error

Connection not validated
Validating DBConnection, URI: jdbc:postgresql://localhost:5432/postgres?user=postgres&password=*****&useSSL=false
Problem validating database connection: 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.
image

but any other application is able to connect Zrzut ekranu 2023-01-29 o 21 34 46

How I runned the server:

$ docker pull tigase/tigase-xmpp-server
$ docker run --name tigase-server -p 8080:8080 -p 5222:5222 tigase/tigase-xmpp-server

kosaa avatar Jan 29 '23 20:01 kosaa

Hi, How do you run postgresql? Via docker as well? If so you should make your postgres container and tigase container use the same dedicated network (see https://github.com/tigase/tigase-xmpp-server-docker/#dedicated-network) and then reference postgres via container name (which is also it's hostname within dedicated network)

woj-tek avatar Jan 30 '23 14:01 woj-tek

I have postgres installed by brew install postgresql

kosaa avatar Jan 31 '23 13:01 kosaa

I would recommend switching to one deployed in docker as well - makes maintenance easier, especially if your other tools also rely on docker. As for your use-case, accessing host services from within docker is somewhat tricky, but possible, see https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container#43541732. In a nutshell: add --add-host=host.docker.internal:host-gateway to your docker run command and then in the installer use host.docker.internal for postgres database.

Alternatively, you can run Tigase without docker - simply download latest distribution package from https://github.com/tigase/tigase-server/releases/tag/tigase-server-8.3.0, extract it and in the directory run ./scripts/tigase.sh start etc/tigase.conf (at least JDK17 has to be installed)

woj-tek avatar Jan 31 '23 14:01 woj-tek

@kosaa

Download the docker-compose.yml file and update the contents

https://tigase.dev/tigase/_server/tigase-server/~raw/master/src/main/docker/docker-compose.yml?disposition=ATTACHMENT

  1. Set the - environment DB_HOST = host.docker.internal inside docker-compose.yml file
  2. Save and run "docker compose up" in the same terminal where docker-compose.yml is located

I think postgres inside the container was struggling to connect to the proper network host

junkeritechnepal avatar Jun 12 '24 15:06 junkeritechnepal

NOTE: Tigase has new home at tigase.dev/tigase/_server/server-core/ - please submit all issues/pull-requests there!

@junkeritechnepal

With the above docker-compose file you shouldn't need to change anything and DB_HOST=db is correct as it points to db service of postgresql.

In kosaa's case it would require DB_HOST = host.docker.internal but he's using database external to docker(-compose)

woj-tek avatar Jun 20 '24 13:06 woj-tek