Is there any issue using the same postgresql database for two different servers? - postgresql

I am using postgres database which is accessed by jboss and tomcat server.
My server accidentally restarted and then postgres service was not showing in the services list.
When I tried to open postgres local host server using pgadminIII it showed following error:
Server doesn't listen
The server doesn't accept connections: the connection library reports
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?
If you encounter this message, please check if the server you're trying to contact is actually running PostgreSQL on the given port. Test if you have network connectivity from your client to the server host using ping or equivalent tools. Is your network / VPN / SSH tunnel / firewall configured correctly?
For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. In order to access the server over the network, you need to enable listening on the address first.
For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use '*' to listen on all available IP addresses. For earlier servers (Version 7.3 or 7.4), you'll need to set the "tcpip_socket" parameter to 'true'.
You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. After changing this file, you need to restart the server process to make the setting effective.
If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. You probably have some low level network connectivity problems (e.g. firewall configuration). Please check this thoroughly before reporting a bug to the PostgreSQL community.
Does this problem arise due to accessing same DB by two different servers?

My server accidentally restarted and then postgres service was not
showing in the services list.
You can't connect because it's not running. You can have as many clients connecting to a PostgreSQL server as your hardware can support - there is no problem with that.
Restart your PostgreSQL service. If it won't, check the logs for why. If you don't know where your PostgreSQL logs are now is a good time to find out. I can't tell you how to restart the service because you haven't said what OS you are running or how you installed PG. Check your documentation.

Related

Remote access to postgresql server windows 10

As the title suggest I'm trying to configure a postgresql server to be accessible remotely. I've followed many guides and viewed some of the other answers here however I'm still having trouble.
The details:
os, windows 10
postgresql version on host is 11.6
postgresql version on remote is 11.2 with anaconda install
I have changed the pg_hba.conf and postgresql.conf to allow for connections to the server.
More specifically I've added the line
host all all xxx.xx.x.0/0 trust
I can verify that the host is listening on local address 0.0.0.0:5432 via netstat.
I can ping the ip of the host from the remote, and I have set windows firewalls on the host to allow connection.
Yet I still recieve the following error when trying to access psql from the remote.
psql: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "xxx.xx.x.144" and accepting
TCP/IP connections on port 5432?```
I had to double check the windows firewall permissions. The connection was enabled but the application was not set to allowed. It turns out a local user can enable connection but I needed the system admin to set the application executable to allowed by the windows fire wall.

Remotely connecting to postgresql server works from my computer does not work from hosting provider's

There is a PostgreSQL server on a Windows computer that I need to access remotely. It's not on the local network. I'm trying to connect to it with pg_pconnect. I have an AMP stack with PHP 7.1.23 on my local Mac computer and I can connect to it just fine. (The connection works, I can make queries, etc.) When I upload the same script to a hosting provider (LAMP stack with PHP 7.1.22) the script does not work anymore.
Warning: pg_pconnect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused
Is the server running on host "x.x.x.x" and accepting
TCP/IP connections on port 5432? in /path/to/my-script on line 42
I would think that the SQL server does not allow remote connections if it didn't allow the connection from my computer either. But to that server both connections would be remote, right? So how can it allow one and not allow the other?
Turned out that the hosting provider had to whitelist the IP address first. That's why it didn't work.

HEROKU POSTGRES error: Connection refused Is the server running on host "..compute-1.amazonaws.com..." and accepting TCP/IP connections on port 5432?

I have been trying for weeks to figure out what's the issue, but I cannot seem to fix this.
I am developing a web app, and I have deployed to production using Heroku. I'm using Heroku Postgres for my database, and I'd like to psql into that hosted database from my local machine to make changes to it. I have tried from both Mac OS X and Linux Mint.
However, no matter what I try, I keep getting the following error:
---> Connecting to HEROKU_POSTGRESQL_ORANGE_URL (DATABASE_URL)
psql: could not connect to server: Connection refused
Is the server running on host "ec2-***-**-***-**.compute-1.amazonaws.com" (***.**.***.**) and accepting
TCP/IP connections on port 5432?
I'm starting to think that I may have to SSH into the Amazon EC2 instance and change the Postgres configuration? Would that even be possible?
You can't connect directly to the EC2 instance where the Heroku Postgres instance is running; it is managed by Heroku and normal users aren't allowed to connect to it.
If your application is running fine in Heroku, and you're running heroku pg:psql to attempt to connect to the DB, then most likely there is some issue with your local network that is preventing you from connecting to the Postgres database, like a firewall blocking outbound connections. Heroku Postgres databases are open to the public without any restriction on IP ranges.
It could be a problem with the proxy or firewall of the internet connection you are using.
Try to connect your PC to your mobile phone tethering and then launch the command again, just to verify if the problem lies there.
I was getting this kind of error when my pg_hba.conf or AWS security groups have not been configured properly. There are plenty of docs about how to resolve this. For example, you can check this list link
You can directly connect to EC2 Heroku Postgress instance by adding this attributes to the end of your DB connection url:
jdbc:postgresql://<host>/<dbname>?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

can not connect to to Postgres in heroku through pgAdmin

I am trying to connect from my office network to the database that create in heroku (Postgres). I am using Pgadmin but the connection fail:
could not connect to server:Connection timed out is the server running on host "ec2-54-204-43-200.compute-1.amazonaws.com" and accepting TCP/IP connections on port 5432?
but when I connect from my home this error doesn't exist so I think is a network issue that I have to resolve but I dont know what to see, just I disable my firewall but even that is not working .
Someone can know what can i do ?
Ok, I got the solution. I talk with the Networking departmment and the problem was to able the ip and port where I needed to connect it in the firewall.

general sql error

I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.