diff --git a/src/libs/qmljsdebugclient/qdeclarativeoutputparser.cpp b/src/libs/qmljsdebugclient/qdeclarativeoutputparser.cpp
index 04b50bc4edc1c3eb13c689d9573ac72b1276a56d..639d8836f57f222f5f4146a563be30b126b12135 100644
--- a/src/libs/qmljsdebugclient/qdeclarativeoutputparser.cpp
+++ b/src/libs/qmljsdebugclient/qdeclarativeoutputparser.cpp
@@ -31,6 +31,7 @@
 
 #include "qdeclarativeoutputparser.h"
 #include "qmljsdebugclientconstants.h"
+#include <QRegExp>
 
 namespace QmlJsDebugClient {
 
@@ -70,7 +71,22 @@ void QDeclarativeOutputParser::processOutput(const QString &output)
             static QString connectionEstablished = QLatin1String(Constants::STR_CONNECTION_ESTABLISHED);
 
             if (status.startsWith(waitingForConnection)) {
-                emit waitingForConnectionMessage();
+                status.remove(0, waitingForConnection.size()); // chop of 'Waiting for connection '
+
+                static QRegExp waitingTcp(
+                            QString::fromLatin1(Constants::STR_ON_PORT_PATTERN));
+                if (waitingTcp.indexIn(status) > -1) {
+                    bool canConvert;
+                    quint16 port = waitingTcp.cap(1).toUShort(&canConvert);
+                    if (canConvert)
+                        emit waitingForConnectionOnPort(port);
+                    continue;
+                }
+
+                static QString waitingOst
+                        = QLatin1String(Constants::STR_VIA_OST);
+                if (status.startsWith(waitingOst))
+                    emit waitingForConnectionViaOst();
             } else if (status.startsWith(unableToListen)) {
                 //: Error message shown after 'Could not connect ... debugger:"
                 emit errorMessage(tr("The port seems to be in use."));
diff --git a/src/libs/qmljsdebugclient/qdeclarativeoutputparser.h b/src/libs/qmljsdebugclient/qdeclarativeoutputparser.h
index 2621d114d59bde6b6e8fdb9d7bd306a643b4401c..7c39a7b973064c7b2cac76539eb0c96bf936ab13 100644
--- a/src/libs/qmljsdebugclient/qdeclarativeoutputparser.h
+++ b/src/libs/qmljsdebugclient/qdeclarativeoutputparser.h
@@ -48,7 +48,8 @@ public:
     void processOutput(const QString &output);
 
 signals:
-    void waitingForConnectionMessage();
+    void waitingForConnectionOnPort(quint16 port);
+    void waitingForConnectionViaOst();
     void connectionEstablishedMessage();
     void errorMessage(const QString &detailedError);
     void unknownMessage(const QString &unknownMessage);
diff --git a/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h b/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h
index a8d7d81b25abb5ff947be30909c286d978f53e61..d4a6eec755cd8e7efddc57be1ba8301e4d87b0da 100644
--- a/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h
+++ b/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h
@@ -5,6 +5,8 @@ namespace QmlJsDebugClient {
 namespace Constants {
 
 const char STR_WAITING_FOR_CONNECTION[] = "Waiting for connection ";
+const char STR_ON_PORT_PATTERN[] = "on port (\\d+)";
+const char STR_VIA_OST[] = "via OST";
 const char STR_UNABLE_TO_LISTEN[] = "Unable to listen ";
 const char STR_IGNORING_DEBUGGER[] = "Ignoring \"-qmljsdebugger=";
 const char STR_IGNORING_DEBUGGER2[] = "Ignoring\"-qmljsdebugger="; // There is (was?) a bug in one of the error strings - safest to handle both
diff --git a/src/plugins/debugger/qml/qmladapter.cpp b/src/plugins/debugger/qml/qmladapter.cpp
index d36b17f4fcd4ee1949b97d9cb7d22d7bc9aa46d7..7ab699eb193ab5237c7b9b805b50ded10cc024bd 100644
--- a/src/plugins/debugger/qml/qmladapter.cpp
+++ b/src/plugins/debugger/qml/qmladapter.cpp
@@ -32,7 +32,6 @@
 
 #include "qmladapter.h"
 
-#include "debuggerstartparameters.h"
 #include "qscriptdebuggerclient.h"
 #include "qmlv8debuggerclient.h"
 #include "qmljsprivateapi.h"
@@ -46,6 +45,7 @@
 
 #include <QTimer>
 #include <QDebug>
+#include <QWeakPointer>
 
 namespace Debugger {
 namespace Internal {
@@ -108,23 +108,28 @@ QmlAdapter::~QmlAdapter()
     delete d;
 }
 
-void QmlAdapter::beginConnection()
+void QmlAdapter::beginConnectionTcp(const QString &address, quint16 port)
 {
     if (d->m_engine.isNull()
             || (d->m_conn && d->m_conn->state() != QAbstractSocket::UnconnectedState))
         return;
 
-    const DebuggerStartParameters &parameters = d->m_engine.data()->startParameters();
-    if (parameters.communicationChannel == DebuggerStartParameters::CommunicationChannelUsb) {
-        const QString &port = parameters.remoteChannel;
-        showConnectionStatusMessage(tr("Connecting to debug server on %1").arg(port));
-        d->m_conn->connectToOst(port);
-    } else {
-        const QString &address = parameters.qmlServerAddress;
-        quint16 port = parameters.qmlServerPort;
-        showConnectionStatusMessage(tr("Connecting to debug server %1:%2").arg(address).arg(QString::number(port)));
-        d->m_conn->connectToHost(address, port);
-    }
+    showConnectionStatusMessage(tr("Connecting to debug server %1:%2").arg(address).arg(
+                                    QString::number(port)));
+    d->m_conn->connectToHost(address, port);
+
+    //A timeout to check the connection state
+    d->m_connectionTimer.start();
+}
+
+void QmlAdapter::beginConnectionOst(const QString &channel)
+{
+    if (d->m_engine.isNull()
+            || (d->m_conn && d->m_conn->state() != QAbstractSocket::UnconnectedState))
+        return;
+
+    showConnectionStatusMessage(tr("Connecting to debug server on %1").arg(channel));
+    d->m_conn->connectToOst(channel);
 
     //A timeout to check the connection state
     d->m_connectionTimer.start();
diff --git a/src/plugins/debugger/qml/qmladapter.h b/src/plugins/debugger/qml/qmladapter.h
index 9ec6dc9015ca15e05582ea765b0e84dc4f83c47d..9abaf2d5aae5c873f5499cf7645fe80e1b9dca88 100644
--- a/src/plugins/debugger/qml/qmladapter.h
+++ b/src/plugins/debugger/qml/qmladapter.h
@@ -62,7 +62,8 @@ public:
     explicit QmlAdapter(DebuggerEngine *engine, QObject *parent = 0);
     virtual ~QmlAdapter();
 
-    void beginConnection();
+    void beginConnectionTcp(const QString &address, quint16 port);
+    void beginConnectionOst(const QString &port);
     void closeConnection();
 
     bool isConnected() const;
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index 52da3723ed419a71702ac6265aa8d650c262c132..d2beefce3a63cfe644a9426f90d41d2ba377e02f 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -172,7 +172,9 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
             SLOT(start()));
 
     d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
-    connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
+    connect(&d->m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
+            this, SLOT(beginConnection(quint16)));
+    connect(&d->m_outputParser, SIGNAL(waitingForConnectionViaOst()),
             this, SLOT(beginConnection()));
     connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
             this, SLOT(beginConnection()));
@@ -235,10 +237,29 @@ void QmlEngine::connectionEstablished()
         notifyEngineRunAndInferiorRunOk();
 }
 
-void QmlEngine::beginConnection()
+void QmlEngine::beginConnection(quint16 port)
 {
     d->m_noDebugOutputTimer.stop();
-    d->m_adapter.beginConnection();
+    if (port > 0) {
+        QTC_CHECK(startParameters().communicationChannel
+                  == DebuggerStartParameters::CommunicationChannelTcpIp);
+        QTC_ASSERT(startParameters().connParams.port == 0
+                   || startParameters().connParams.port == port,
+                   qWarning() << "Port " << port << "from application output does not match"
+                   << startParameters().connParams.port << "from start parameters.")
+        d->m_adapter.beginConnectionTcp(startParameters().qmlServerAddress, port);
+        return;
+    }
+    if (startParameters().communicationChannel
+           == DebuggerStartParameters::CommunicationChannelTcpIp) {
+        // no port from application output, use the one from start parameters ...
+        d->m_adapter.beginConnectionTcp(startParameters().qmlServerAddress,
+                                        startParameters().qmlServerPort);
+    } else {
+        QTC_CHECK(startParameters().communicationChannel
+                  == DebuggerStartParameters::CommunicationChannelUsb);
+        d->m_adapter.beginConnectionOst(startParameters().remoteChannel);
+    }
 }
 
 void QmlEngine::connectionStartupFailed()
@@ -393,8 +414,6 @@ void QmlEngine::runEngine()
     if (!isSlaveEngine()) {
         if (startParameters().startMode != AttachToRemoteServer)
             startApplicationLauncher();
-        else
-            beginConnection();
     }
 }
 
diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h
index abf80cbb1dc94ccc81b89eee2fe349c98e461390..c6170bbc917336593c4674644d0f75b783da0df5 100644
--- a/src/plugins/debugger/qml/qmlengine.h
+++ b/src/plugins/debugger/qml/qmlengine.h
@@ -159,7 +159,7 @@ signals:
         TextEditor::ITextEditor *editor, int cursorPos);
 
 private slots:
-    void beginConnection();
+    void beginConnection(quint16 port = 0);
     void connectionEstablished();
     void connectionStartupFailed();
     void connectionError(QAbstractSocket::SocketError error);
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
index 500582a3ec1d694d00f0a00811782260315b32f3..5487711e68d7273a0599a400025c5002a49d4308 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
@@ -149,7 +149,9 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
     connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(processIsRunning()));
 
     d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
-    connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
+    connect(&d->m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
+            this, SLOT(processIsRunning(quint16)));
+    connect(&d->m_outputParser, SIGNAL(waitingForConnectionViaOst()),
             this, SLOT(processIsRunning()));
     connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
             this, SLOT(processIsRunning()));
@@ -331,10 +333,19 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
     noExecWarning->show();
 }
 
-void QmlProfilerEngine::processIsRunning()
+void QmlProfilerEngine::processIsRunning(quint16 port)
 {
     d->m_noDebugOutputTimer.stop();
-    emit processRunning(d->m_runner->debugPort());
+
+    QTC_ASSERT(port == 0
+               || port == d->m_runner->debugPort(),
+               qWarning() << "Port " << port << "from application output does not match"
+               << startParameters().connParams.port << "from start parameters.");
+
+    if (port > 0)
+        emit processRunning(port);
+    else
+        emit processRunning(d->m_runner->debugPort());
 }
 
 } // namespace Internal
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.h b/src/plugins/qmlprofiler/qmlprofilerengine.h
index 9969d2a3a7f178a29564dc7c5c54f993883ee740..b0199c31312dd721b978a05b57db4a9ae40413f8 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.h
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.h
@@ -70,7 +70,7 @@ private slots:
     void logApplicationMessage(const QString &msg, Utils::OutputFormat format);
     void wrongSetupMessageBox(const QString &errorMessage);
     void wrongSetupMessageBoxFinished(int);
-    void processIsRunning();
+    void processIsRunning(quint16 port = 0);
 
 private:
     class QmlProfilerEnginePrivate;
diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
index 469024decc081a235964e2c30328d90893d7d529..d108a1619bb0d9d9d852f3721571968c6bffa4dc 100644
--- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
@@ -99,7 +99,7 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
     if (runConfig->useQmlDebugger()) {
         params.languages |= QmlLanguage;
         params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
-        params.qmlServerPort = -1;
+        params.qmlServerPort = 0; // port is selected later on
     }
     if (runConfig->debuggerAspect()->useCppDebugger()) {
         params.languages |= CppLanguage;