diff --git a/examples/emcute/main.c b/examples/emcute/main.c
index 520cae9bf9706bd09c609a19d3f49b01d6b5cea2..2a7a770406e433165bf702214316b0a7c08d7857 100644
--- a/examples/emcute/main.c
+++ b/examples/emcute/main.c
@@ -99,6 +99,7 @@ static int cmd_con(int argc, char **argv)
 
     if (emcute_con(&gw, true, topic, message, len, 0) != EMCUTE_OK) {
         printf("error: unable to connect to [%s]:%i\n", argv[1], (int)gw.port);
+        return 1;
     }
     printf("Successfully connected to gateway at [%s]:%i\n",
            argv[1], (int)gw.port);