Cargo plugin unable to deploy

Hi, I am trying to deploy my web appplication to tomcat 8.5.
Here goes my build file.

plugins {
    id "com.bmuschko.cargo" version "2.2.3"
    id 'nu.studer.credentials' version '1.0.1'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'war'

group = 'com.nautilus'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {

dependencies {

cargo {
    containerId = 'tomcat8x'
    port = 8080

    remote {
        hostname = 'localhost'
        username = project.credentials.("manager.username")
        password = project.credentials.("manager.password")

    deployable {
        file = file('build/libs/my.war')
        context = 'my-context'

I am try to run next commands
gradle war cargoDeployRemote
gradle war cargoRedeployRemote

but I am getting the next error

:cargoDeployRemote (Thread[Task worker,5,main]) completed. Took 1.825 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cargoDeployRemote'.
> org.codehaus.cargo.container.ContainerException: Failed to deploy [E:\programming-projects\java\nautilus\nautilus-app\build\libs\my.war]

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cargoDeployRemote'.

Caused by: : org.codehaus.cargo.container.ContainerException: Failed to deploy '
Caused by: org.codehaus.cargo.container.ContainerException: Failed to deploy ..
Caused by: Software caused connection abort: recv failed

P.S. I know that for localhost there are local configuration but in future it will be replaced with a real host.

I see nothing wrong with the configuration in your build script. The issue you are seeing is likely happen due to some network misconfiguration or a firewall blockage. Try to shut down your firewall and see if it works. Also make sure you create the manager user and role in Tomcat.

Thank you for your answer.
I have tried to turn off Windows Firewall, Kaspersky antivirus, Firewall in Kaspersky.
Here goes my tomcat-users.xml

  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user username="admin" password="admin" roles="manager-gui,admin-gui,manager-status,manager-script,manager-jmx"/>

Here goes apache-tomcat-8.5.13\webapps\host-manager\META-INF\context.xml

<Context antiResourceLocking="false" privileged="true" >
  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

If that didn’t help then I’d suggest asking on the Cargo forum. The Gradle plugin is just configuring the Cargo Ant task under the covers. The actual failure comes from a Cargo class (see stack trace you provided). You might want to run with -s to potential get more information.

RE: credentials the following should be good enough:

<role rolename="manager-script"/>
<user username="manager" password="manager" roles="manager-script"/>

I am new to gradle.Below is my build.gradle.

import org.ajoberstar.grgit.*
import com.bmuschko.gradle.cargo.convention.Deployable
import com.bmuschko.gradle.cargo.tasks.remote.CargoDeployRemote
import com.bmuschko.gradle.cargo.tasks.local.CargoStartLocal
import com.bmuschko.gradle.cargo.tasks.local.CargoStopLocal

buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.ajoberstar:grgit:1.3.0’
classpath ‘com.bmuschko:gradle-cargo-plugin:2.3’
repositories { mavenCentral() }
apply plugin: 'java’
apply plugin: 'war’
apply plugin: ‘com.bmuschko.cargo’

dependencies {

def cargoVersion = '1.6.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",

cargo {
	containerId = 'tomee1x'
	port = 8080

	deployable {
		file= file('D:/apps/apache-tomee-plus-')
		context = 'enovia'
		protocol = 'http'
		hostname  = 'localhost'
		username = 'tomee'
		password = 'tomee'

I am also getting similar error.:

Caused by: org.codehaus.cargo.container.ContainerException: Failed to redeploy [
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDep
at org.codehaus.cargo.ant.CargoTask.executeActions(
at org.codehaus.cargo.ant.CargoTask.execute(
… 125 more
Caused by: Connection refused: connect
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(Tom
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(Tomca
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDep
… 129 more

Can anyone help me on this?