title: Embedded tomcat java application is running, but server cannot be reached
body: <p>I am trying to set up a basic embedded Tomcat server and am unable to get the Tomcat server to run.</p>
  <pre class="lang-java prettyprint-override"><code>public class Main {
  
      public static void main(String[] args) throws LifecycleException {
  
          Tomcat tomcat = new Tomcat();
          tomcat.setPort(8888);
  
          tomcat.start();
          tomcat.getServer().await();
      }
  }
  </code></pre>
  <p>Running this java app in Eclipse provides the output:</p>
  <blockquote>
  <p>June 19, 2019 12:00:00 PM org.apache.catalina.core.StandardService startInternal</p>
  <p>INFO: Starting service [Tomcat]</p>
  </blockquote>
  <p>And then waits until I hit stop, as expected, but when I run <code>curl localhost:8888</code> in the terminal, i get <em>curl: (7) Failed connect to localhost:8888; Connection refused</em>.</p>
  <p>I've followed <a href="http://zetcode.com/web/embeddedtomcat/" rel="noreferrer">this</a> tutorial exactly, but I cannot seem to get the <em>server</em> to actually run. Also, <code>netstat -nlt</code> does not show the port <code>8888</code> being open.</p>
  <p>My <code>build.gradle</code> has a single dependency:</p>
  <pre><code>implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.21'
  </code></pre>
  <p>Is there something I'm missing here?</p>