Attempting to access page using IP address instead of localhost

13,276

Ah! New data!

You posted a screenshot, and you mentioned you tried to set up another web server using a different tutorial. Well, it WORKED. The "It Works!" page is the standard go-to page for apache servers, and I would assume others. It exists to tell you that you have, in fact, successfully set up a web server.

So:

My guess is that the problem lies in a config file. Since you stated that it DOES work with localhost, it would appear that there is some redirecting happening. If the traffic is coming internally from the machine, then it displays what you want. If the traffic is from elsewhere, however, it redirects to the "itworks" page.

A thought occurs to me. Is it possible you currently have TWO web servers running right now? If you do, they are on separate ports, so you will have to adjust your url (and various program settings, etc) accordingly.

Edit (from comments): Make sure that you are only running one web server at a time when you first start off. If you have more than one running, it can be difficult to determine which one you are targeting. Leave your code alone until you make sure only one instance of one webserver is running, and that it is configured enough for you to get the "It works" page up. THEN worry about code. Otherwise, your code may be perfect.....just being targeted by the webserver you don't know about.

Share:
13,276
Keshava Murthy
Author by

Keshava Murthy

Updated on June 04, 2022

Comments

  • Keshava Murthy
    Keshava Murthy almost 2 years

    I was working through the following tutorial: http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html

    And I've managed to get it working. I can type in

    http://localhost/test-app/ 
    

    and it displays (on my computer obviously) exactly what I want to see. (Which is, of course, fantastic.)

    However, I'm now looking to port this out so that I can view that same page from other computers. I know I need to be on the same network, and I am, but I can't figure out how to see that page. I've tried using:

    My IP address is 155.198.X.X and I'm using port 80.

    http://155.198.X.X/test-app (didn't work)
    http://155.198.X.X:80/test-app (didn't work either)
    

    These don't work on either my computer or other computers on the same network.

    I'm using Tomcat 7.0 and Eclipse for my code.

    Am I missing something?

    Cheers, Kesh

    EDIT:

    I'm starting to think that it's something to do with when I tried earlier to set up a server. I did another tutorial. Basically, every time I put my web server's IP address in to a computer, the following text appears: "It works!".

    Sample

    Does this have anything to do with it?

  • Keshava Murthy
    Keshava Murthy almost 11 years
    I think I have two web servers running! I must do, because I've been playing around with this for a while. I assumed that when I deleted the code for the other server, it would have stopped running that. How do I adjust my URL for that though? Like I said in the question, even if I put the right port in, it doesn't work.
  • Keshava Murthy
    Keshava Murthy almost 11 years
    By the way, the "It works" page comes up if I just type "localhost" into my computer as well...
  • Russell Uhl
    Russell Uhl almost 11 years
    @KeshavaMurthy Well you need to kill the other webserver. You need to find the process, end it, then UNINSTALL the other webserver, or at the very least disable it from running on startup. At this point, it's probably a good idea to reboot, just so you can confirm things are still working. THEN you reconfigure the second webserver, the one you want working, to point at port 80 (this step may or may not be necessary). After that, go to localhost to make sure it's running and you get the It Works page. Once you reach this point, you start worrying about code.
  • Keshava Murthy
    Keshava Murthy almost 11 years
    Cheers mate, that's definitely got to be the answer here. I'll put a tick by your solution =]
  • Keshava Murthy
    Keshava Murthy almost 11 years
    I forgot to mention, do you want to add the text from the comments into the original solution - might be easier for lurkers.