How to resolve java.net.ConnectException: Connection refused - java

i am running my android application in device its not connecting to device.Its giving following error
[2016-10-24 19:41:00 - DeviceMonitor] Failed to start monitoring 127.0.0.1:5558
[2016-10-24 19:41:17 - Device] Error during Sync: Connection refused: connect
[2016-10-24 19:41:38 - Device] Error during Sync: Connection refused: connect

Try giving user permission to your manifest
<uses-permission android:name="android.permission.INTERNET" />

If you are sure that the server IP address and port number correct then my answer will not be so helpful.
Otherwise: - Especially if you are using different JVMs for the client android app and the java program(your server). This could happen probably because they are both referencing different localhosts.
Open command line and issue the command ipconfig you will get details about your network configurations. Instead of localhost Use the physical address of your computer(IPv4 address displayed on your terminal), it looks something like below.

Related

Could not Connect User to Service in Android Studio

I am using Android Studio 2.3. When I am attaching my Moto G4 to debug an application, it ends up with the following error in Android Monitor.
6333-7189/? I/XMPPConnection: Preparing to connect user 1576857969013772288 to service: on host: and port: 0
03-25 11:06:18.221 6333-7189/? E/XMPPConnectionManager: Failed to connect user '1576857969013772288' to host ' on port 0: XMPPError connecting to :0.: remote-server-error(502) XMPPError connecting to :0.
-- caused by: java.net.ConnectException: Connection refused
After this error, no further logs are captured even in verbose mode.
Check below Links:
https://stackoverflow.com/a/6876306/3992798
I am having a similar problem.
I have an application running on Websphere 7 Dev environment
http://appl.company.com/appl/home.action
And also on my localhost system
http://localhost/appl/home.action
I am trying to access a URL like below
http://appl.company.com/SiteContent/a.html from the above application
It works perfectly fine on my local system.
But on the development environment, on this particular line :-
String stream = (new java.net.URL(url)).openStream();
I am getting a "java.net.ConnectException: Connection refused" exception
On googling i figured, such problems are either due to one of the following
The port is wrong (cannot be this option, as same url running perfectly from local system)
Firewall is stopping it.
The Android SDK, do you config the path?
try to it what open a cmd window,input 'adb devices',see result waht display a device of you Moto

Java Mission Control: Flight Recorder throws: javax.naming.ServiceUnavailableException

I am trying to profile a Java Spring application with the Oracle Java Mission control.
I have the JVM Connection configured as: localhost:7091
and I started the application with java -Dcom.sun.management.jmxremote.rmi.port=7091 -jar app.jar.
When I attempt to start the flight recorder I get an error message.
Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
Could not connect to a JVM at service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi. Make sure one is running and that you are using the correct protocol in the Service URL.
Does anyone know what could be the reason for that error?
You could try to use auto discovery. Then the connection will show up automatically in JMC
-Dcom.sun.management.jmxremote.autodiscovery=true
You can also name the connection so you can identify it easily.
-Dcom.sun.management.jdp.name=App
and disable security
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I had this issue. I had installed JDK 10 on Windows Server 2016. With JMC and the JVM I wished to monitor on the same server.
When going live, we switched the IP from a temporary IP to a live IP. However, JMC resolved localhost to the original IP. Also when specifying the server's current IP, JMC resolved it to the original IP.
Adding -Djava.rmi.server.hostname=localhost to the Java process I wanted to monitor, resolved the issue.
However, I will would still be interested to know why JMC (or RMI) still resolves incorrectly.

connect failed: ECONNREFUSED

I am developing one app, and what I think I wanna do is receive data from server database in android. So I started to run some tutorials. I found one that is doing pretty much what I want.
But I am getting:
detailMessage "failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused)" (id=830021648792)
Whole code of this tutorial is here link
Error occurs on :
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
I checked that:
firewall is disabled
ping is working
connection string is exactly the same as when I run the servlet from server admin interface - http://localhost:8080/Requestor/RQSRV
-the servlet is running
My configuration :
Server : Glass Fish 4.0
Android App - Developed in Eclipse
Servlet - Developed in NetBeans
To access your PC localhost from Android emulator, use 10.0.2.2 instead of 127.0.0.1. localhost or 127.0.0.1 refers to the emulated device itself, not the host the emulator is running on.
Reference: https://developer.android.com/studio/run/emulator-networking#networkaddresses
For Genymotion use: 10.0.3.2 instead of 10.0.2.2
if you are using genymotion then go to command prompt type ipconfig
-find for Ethernet adapter virtualBox host-only network:
-find for Ipv4 Address..............192.1**.**.*
copy
http://192.1..*/foldername/filename/filename.json or filename.php
to check if its working go to browser in emulator copy paste the url you should find the file which you are looking in your browser..
Sorry for English..
This worked for me hope this might help some one..
Thank u..

connecting to postgreSQL server failed

I am trying to install "Kwok information server" and I am new to postgreSQL. I just followed the installation guide of Kwok information server.
when I am trying to install kwok-schema-setup.jar file using java through postgreSQL server in Command Prompt, I am getting the following error..."Connecting to PostgreSQL Server ...failed. Connection refused. Check that the ho
stname and port are correct and that the postmaster is accepting TCP/IP connecti
ons. Cause: java.net.ConnectException: Connection refused: connect
Schema setup encountered errors" .
And when I am trying to connect to the server using pgAdmin III, I am getting the 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 "127.0.0.1" and accepting TCP/IP connections on port 5432? ".
Please anyone help me regarding, Thanks in advance!!
Looks like your Postgresql daemon is not running. Check if the server has started and is running. I dont know which OS you are using but try ps -ax on linux/mac or the task manager in windows.
Maybe a firewall that is blocking the connection, you have to provide more information about your environment to be sure.

Netbeans can't start derby server

I've been trying to start the server but I get this error message:
2013-01-23 19:24:18.133 GMT : Security manager installed using the
Basic server security policy. 2013-01-23 19:24:18.430 GMT : Could not
listen on port 1527 on host localhost: java.net.BindException: Cannot
assign requested address: JVM_Bind
On top of that I get a prompt saying:
Unable to connect. Cannot establish a connection to
jdbc:derby://localhost:1527/sample using
org.apache.derby.jdbc.ClientDriver (java.net.SocketException : Error
connecting to server localhost on port 1527 with message Network is
unreachable: connect.).
How is one suppose to fix such an issue?
I had the same issue but my problem was I had my loopback (lo) network interface disabled... took me quite long to discover... (But most common would be another instance of derby already running I think)

Categories