Question

Java Application not working in browser "refused to connect."

I have installed my app in /home/XXXXX/


/home/
|— prizm-dist/
| |— conf/
| |— jre/
| | |— [jre files]
| |— prizm_db/
| |— html/
| |— logs/
| |— run.sh
| |— run_test.sh
| |— prizmEngine.jar

Above is complete file structure

I am trying to access my app in browser but getting error

refused to connect. Try: Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED

My app is trying to use Port : 9976

I have enabled UFW 9974:9976

I have also installed Java Package in my Droplet, but still I am not able to access my app. Please help


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
June 23, 2023

Heya,

Based on the information provided, there could be multiple reasons why your Java application is not accessible. Here are a few troubleshooting steps:

  1. Check if the Application is Running: Ensure that your application is running. You can do this by using the following command:
ps -ef | grep prizmEngine.jar

If your application is running, you should see it listed in the results.

  1. Check Port Listening: Ensure that your application is actually listening on port 9976. You can check the ports that are currently in use with the command:
sudo netstat -tuln | grep 9976

If your application is listening on the correct port, you should see it listed in the results.

  1. Check Firewall Rules: Ensure that your firewall rules are allowing connections on port 9976. It’s good that you’ve mentioned you enabled the port in UFW, but do verify it with:
sudo ufw status

The ports 9974 to 9976 should be listed as allowed in the output.

  1. Ensure No Other Service is Using the Same Port: Ensure that no other service is using port 9976. If another service is using this port, your application will not be able to bind to it.

  2. Check Application Logs: Check the logs for your application to see if there are any error messages. The logs directory is generally a good place to start.

  3. Check Java Version: Ensure that you have the correct version of Java installed. You can check this by running java -version from the command line. The version of Java you have installed should be compatible with your application.

  4. Check Your Network Settings: If your droplet is set to listen only on localhost (127.0.0.1), you will not be able to access the application from the outside world. Make sure your application is set up to listen on 0.0.0.0 (all interfaces) or a public-facing IP address.

Remember, the best way to diagnose these problems is by looking at your application logs, which can provide detailed error messages. If you still cannot find the problem, please provide additional information or error logs, if any.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel