title: tomcat:deploy: "Cannot invoke Tomcat manager: Connection refused"
body: <p>I tried to deploy my app to Tomcat using Maven and I've found <a href="http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/">this</a> sample.</p>
  
  <p>That's fragment of my pom.xml:</p>
  
  <pre><code>    &lt;!-- Maven Tomcat Plugin --&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
              &lt;url&gt;http://127.0.0.1:8080/&lt;/url&gt;
              &lt;server&gt;TomcatServer&lt;/server&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;!-- Maven compiler plugin --&gt;
      &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
              &lt;source&gt;1.6&lt;/source&gt;
              &lt;target&gt;1.6&lt;/target&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  </code></pre>
  
  <p>And when I run <code>tomcat:deploy</code> I get this error: <code>Cannot invoke Tomcat manager: Connection refused</code>. That's full stacktrace:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project webapp: Cannot invoke Tomcat manager: Connection refused: connect -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project webapp: Cannot invoke Tomcat manager
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
      at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
      at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      ... 25 more
  Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
      at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:227)
      at sun.net.www.http.HttpClient.New(HttpClient.java:300)
      at sun.net.www.http.HttpClient.New(HttpClient.java:317)
      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
      at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:597)
      at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
      at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
      at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
      at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
      at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
      ... 28 more
  </code></pre>
  
  <p>I didn't want to use authentication so I just skipped those steps. I thought that this may cause my error, but when I tried to add them, nothing changed. Do you know where's my mistake?</p>
  
  <p><strong>UPD:</strong> Sorry, but I can't check our solutions because I'm not working on this project anymore. But I will not close this question so if you think that your solution will work feel free to left it here and may be it will help to someone.</p>