java.net.ConnectException: Connection refused: connect - sockets

trying to upload file using apache file upload, but getting this error:
java.net.ConnectException: Connection refused: connect
it was working yesterday, but today it is not working

Either the firewall configuration (by which I mean port forwarding, not access rules) has changed or the server process isn't running.

If this is a locally hosted server. make sure the correct port is forwarded for the correct IPV4, they change often and without much reason.

Related

Connection Refused #Work around startup races

I have this server, client code in which we run the server as a subprocess in py.test and create a client object and connect it with client.
But I am getting the Connection Refused error, when I am tracing it to open() function wherein the socket is trying to connect to ip and port.
There a comment is mentioned that For Connection refused errors, work around startup races.
What are the different ways, I can fix the startup race issue?

psycopg2.OperationalError: could not connect to server: Connection refused - Same code works from one system but not from another

I am trying to connect to redshift and the same code (same host, User, DB name, pwd, port) works from one computer but throws connection refused error from another one . Both the systems first connect to VPN and trying to connect to database. Not sure if any of the config file needs to be updated with IP ? Not sure what could be the reason.
psycopg2.OperationalError: could not connect to server: Connection refused
Is server running on host xxx.xx.xx.xx and accepting TCP/IP connections on port YYYY
"Connection refused" means it couldn't even get ahold of the database to attempt to establish a connection with it. Whatever is going on is happening at the networking level, not within the database.

php: fbird_connect(): Unable to complete network request to host "localhost". Failed to establish a connection [duplicate]

I'm trying to connect to a remote Firebird database "test" (alias already added). It is not an embedded server, and is installed on VM with IP 192.168.1.147.
Here is my connection string:
User=sysdba;Password=masterkey;Database=test;DataSource=192.168.1.147
However I got an error:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Unable to complete network request to host "192.168.1.147". ---> Unable to complete network request to host "192.168.1.147".
I've done some research on that but haven't got a clue yet. Some help needed. Thanks
My IP address is 192.168.2.108, and I can ping that server IP successfully
Make sure that
Firebird is running
Firebird is listening on port 3050 on the specified IP (or on 0.0.0.0)
Your firewall allows access to port 3050
You're using the correct host name
For Linux, the Firebird port is closed by default. You need to modify RemoteBindAddress in /etc/firebird/2.5/firebird.conf from
RemoteBindAddress = localhost
to
RemoteBindAddress =
and restart service.
Make sure you have excluded tcp port 3050 in VMs' firewall.
Ok. I think your connection to firebird is faililing because the firebird client looks up the network service file by name and does not find gds_db in the services file.
If your connection string refers to the host by using IP, the Client might fail to identify it because it gethostbyname() and not by IP
Manually include this in the file and you should be fine.
C:\windows\system32\drivers\etc\services

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.

Unable to connect to PostgreSQL

I am trying to access a table from PostgreSQL present in other machine.
I am getting the following error.
Connection refused. Check that the hostname and port are correct and that the
postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:136)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
I have configured my ip in pg_hba.conf file as well but the same error exists. What could be the solution for it?
Can you telnet to the IP address and port number where you think PostgreSQL is listening?
If not, the trouble is that the postmaster is not running, or that you have something screwball in your network - firewalls blocking access to the port, or can't locate the host or whatever.
If you can get to the postmaster via telnet, then it may be that you've given the wrong credentials or something - but the error suggests that your client code is unable to find the remote PostgreSQL. More likely, though, the configuration being used by the Java code is not the same as the one you successfully demonstrated as working with telnet.
I am new to PostgreSql but i also had a same problem so many times, at last i found solution.
The problem was with firewall blocking port (for Ex : 5432) , once this was granted access through the firewall, i was able to connect to the database server.
You have to add only port which you are using in postgreSql to Firewall.
after this my postgreSql works Fine with Jdbc.
What is the setting for "listen_addresses" in postgresql.conf?
SHOW listen_addresses;
And did you reload the configurationfiles after the changes in pg_hba.conf and postgresql.conf?
SELECT pg_reload_conf();
I has same problem. I added following entry in pg_hba.conf and worked. Make sure you restart postgres after changin configuration file
host all all 0.0.0.0/0 md5