Why does my WebApp fail to run when I'm offline?

By: Steve Peters

Abstract: How to create a hosts file so that Web Applications run even when you're not connected to a network.


Question:

My WebApp throws exceptions or doesn't start at all when I'm not connected to a network. How can I fix this?
 
Answer:

Running your WebApp inside JBuilder requires that your machine have an identifiable hostname. Usually if you are on a network, you have already chosen one or one has been assigned to your computer. However, in some cases you may not have a hostname and not have any way to get one.

All you need in this case to make your WebApp run is a 'hosts' file. Most computers have these files installed when TCP/IP protocol is installed but if you don't have one, here's what to do:

  1. For Windows:
    1. Open Explorer and navigate to C:\winnt\system32\drivers\etc
    2. Create a new text file named hosts
    3. Add this line to it:

      127.0.0.1 localhost

  1. For Linux:
    1. Open a console and change to the /etc directory
    2. With your text editor of choice, create a file called hosts
    3. Add this line to it:

      127.0.0.1 localhost.localdomain localhost

  1. For Solaris:
    1. Open a console and change to the /etc directory
    2. With your text editor of choice, create a file called hosts
    3. Add this line to it:

      127.0.0.1 localhost

Having that file present on your system with the entry for localhost should allow your WebApps to run.
 

Server Response from: ETNASC03