francesco
francesco

Reputation: 2153

Can't access Tomcat using IP address

I'm running a Tomcat 5.5 instance (port 8089) on Windows 7.

The server runs correctly if I open http://localhost:8089/ but it gives me an error (Connection refused) on http://192.168.1.100:8089/

I thought it was a firewall issue, so I disabled it, but I still have no luck.

Upvotes: 49

Views: 208021

Answers (13)

Dominik Kern
Dominik Kern

Reputation: 128

To be accessible via IP (1.2.3.4) and hostname (localhost), I changed the Engine line in server.xml to

    <Engine name="Catalina" defaultHost="localhost" Host="1.2.3.4">

using Apache Tomcat/9.0.58 (Ubuntu).

Upvotes: 1

Stefan Kallinich
Stefan Kallinich

Reputation: 11

Thanks for all answers. For me it was a different issue. I had to set my wireless network to "private". I only need tomcat for network internal use. For some reason although firewall rule was set to allow for all, it does not allow access from within the same network if set to public.

Changing settings in server.xml were not needed in this usecase.

Upvotes: 1

Saket Yadav
Saket Yadav

Reputation: 1017

Windows Firewall cause issue after uninstalling Oracle JDK and installing OpenJDK on Windows Server 2008 R2.

Tomcat 7 and Tomcat 8 not access on other machine after this.

Follow below path to add new rule

 --> Windows Firewall with Advanced Security on Local Computer
 --> Inbound Rule 
 -->Add New Rule 
      with specific port you have required for Tomcat application.

Upvotes: 0

Md Sufi Khan
Md Sufi Khan

Reputation: 1761

No solution mentioned above was solved my problem. My problem was different.

First check is your port is disabled in firewall. Go to Control Panel -> Windows Firewall -> Advance Settings -> Inbound Rules and see any port is blocked.

A sample image is below:

enter image description here

If so then you can unblock the port by following steps:

Step 1:

enter image description here

Here you can see that the port is blocked.

enter image description here

Step 2: Allow the connection -> Apply -> Ok.

enter image description here

That's solved my blocked problem. Happy coding :) :)

Upvotes: 3

Ankit Gupta
Ankit Gupta

Reputation: 786

If you are not able to access tomcat from remote, there might be reason that taken port is not open in your machine. Suppose you have taken 8081 port.

On Your windows machine:

Open Control panel-> windows Firewall-> Advance setting->Inbound Rules

Create a new rule: mention Port

Picture1

Configure your port and then shutdown and start your tomcat and it will be accessible from remote as well.

That port issue majorly comes in AWS machines.

If it is still not working then please check with your administrator that selected port is open for public access or not, if not then open it.

Upvotes: 17

amit
amit

Reputation: 1

Very strange because the firewall caused the issue.

Upvotes: 0

Rahul Bagal
Rahul Bagal

Reputation: 230

I was also facing same problem on Amazon windows EC2 instance ( Windows Server 2012 R2 ) Then I figured out , it was local windows firewall preventing it . I opened port 80 ( defined port for website ) using windows Firewall with Advance Security .

It resolved the issue .

Upvotes: 0

zeroRooter
zeroRooter

Reputation: 100

Firewalls are often the problem in these situations. Personally, the Mcafee enterprise firewall was causing this issue even for requests within the network.

Disable your firewalls or add a rule for tomcat and see if this helps.

Upvotes: 1

Udit Kapahi
Udit Kapahi

Reputation: 2337

If you are trying to access your web app which is running on apache tomcat server, it might be working perfect while you are trying to use it on http://localhost:8080/ , it will not work same if you are trying to access it on your mobile device browser for ex. chrome using http://192.168.x.x:8080/ so if you want to access via ip address on your remote/mobile device , do following settings

  1. Open server.xml file.
  2. Change

    <Connector connectionTimeout="20000" port="8080"protocol="HTTP/1.1" redirectPort="8443"/>
    

to.

    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" address="0.0.0.0" />
  1. Save the file
  2. Stop and restart the server
  3. Now access on your mobile device using ip address http://192.168.1.X:8080/

You are good to go.

Upvotes: 16

McKracken
McKracken

Reputation: 678

You need to make Tomcat listen to 192.168.1.100 address also.

If you want it to listen to all interfaces (IP-s) just remove "address=" from Connector string in your configuration file and restart Tomcat.

Or just use your IP to listen to that address address=192.168.1.100 in the Connector string

Upvotes: 23

Suresh Kumar
Suresh Kumar

Reputation: 1

Check your windows-firewall feature in control panel. Outbound and inbound port should allow port 8089. (or write a new rule for this- Right hand side, actions - new rules.) it worked for me!

Upvotes: 0

Anto Binish Kaspar
Anto Binish Kaspar

Reputation: 1332

You need allow ip based access for tomcat in server.xml, by default its disabled. Open server.xml search for "

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           URIEncoding="UTF-8"
           redirectPort="8443" />

Here add a new attribute useIPVHosts="true" so it looks like this,

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           URIEncoding="UTF-8"
           redirectPort="8443"
           useIPVHosts="true" />

Now restart tomcat, it should work

Upvotes: 29

Mohamed Mansour
Mohamed Mansour

Reputation: 40159

New versions of application servers removed the ability of binding to your entire network interface and limited it just to the local interface (localhost). The reason being was for security. From what I know, Tomcat and JBoss implement the same security measures.

If you want to bind it to another IP you can explicitly set it in your connector string:

  • Tomcat: address="192.168.1.100"
  • JBoss: you pass in a -b 192.168.1.100 as a command line.

Just remember that binding 0.0.0.0 allows anyone access to your box to access that server. It will bind to all addresses. If that is what you want, then use 0.0.0.0, if it isn't then specify the address you would like to explicitly bind instead.

Just make sure you understand the consequences binding to all addresses (0.0.0.0)

Upvotes: 12

Related Questions