diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
index 5108b7bd2451a58430a81a7a7431c15c1eedcefd..2b919e7f429a52ec6ae1d046fa8a8e70d7e28e44 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
@@ -168,7 +168,7 @@ void QmlProfilerClientManager::retryConnect()
 {
     if (m_server.scheme() == "socket") {
         startLocalServer();
-    } else if (!m_server.host().isEmpty() && m_server.port() > -1) {
+    } else if (!m_server.host().isEmpty() && m_server.port() > 0) {
         disconnectClient();
         connectToTcpServer();
     } else {
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
index 3c7d65b2bf4a236f7484057ed9e1c5c6dc99bfb7..81bb0fc2671a790f1e2815322c5524a6a2c38006 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
@@ -63,6 +63,8 @@ using namespace QmlProfiler::Internal;
 
 namespace QmlProfiler {
 
+static QString QmlServerUrl = "QmlServerUrl";
+
 //
 // QmlProfilerRunControlPrivate
 //
@@ -72,8 +74,7 @@ class QmlProfilerRunner::QmlProfilerRunnerPrivate
 public:
     QmlProfilerStateManager *m_profilerState = 0;
     QTimer m_noDebugOutputTimer;
-    bool m_isLocal = false;
-    QUrl m_serverUrl;
+    bool m_isAutoStart = false;
     ProjectExplorer::ApplicationLauncher m_launcher;
     QmlDebug::QmlOutputParser m_outputParser;
 };
@@ -86,6 +87,7 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
     : RunWorker(runControl)
     , d(new QmlProfilerRunnerPrivate)
 {
+    setDisplayName("QmlProfilerRunner");
     runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
     runControl->setSupportsReRunning(false);
 
@@ -110,8 +112,7 @@ void QmlProfilerRunner::start()
     Internal::QmlProfilerTool::instance()->finalizeRunControl(this);
     QTC_ASSERT(d->m_profilerState, return);
 
-    QTC_ASSERT(connection().is<UrlConnection>(), return);
-    QUrl serverUrl = connection().as<UrlConnection>();
+    QUrl serverUrl = this->serverUrl();
 
     if (serverUrl.port() != -1) {
         auto clientManager = Internal::QmlProfilerTool::clientManager();
@@ -123,11 +124,9 @@ void QmlProfilerRunner::start()
 
     d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
 
-    if (d->m_isLocal) {
-        QTC_ASSERT(!d->m_serverUrl.path().isEmpty() || d->m_serverUrl.port() != -1, return);
-
+    if (d->m_isAutoStart) {
         StandardRunnable debuggee = runnable().as<StandardRunnable>();
-        QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, d->m_serverUrl);
+        QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, serverUrl);
 
         if (!debuggee.commandLineArguments.isEmpty())
             arguments += ' ' + debuggee.commandLineArguments;
@@ -243,8 +242,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port)
 {
     d->m_noDebugOutputTimer.stop();
 
-    QTC_ASSERT(connection().is<UrlConnection>(), return);
-    QUrl serverUrl = connection().as<UrlConnection>();
+    QUrl serverUrl = this->serverUrl();
     if (!port.isValid())
         port = Utils::Port(serverUrl.port());
 
@@ -284,8 +282,21 @@ void QmlProfilerRunner::profilerStateChanged()
 
 void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl)
 {
-    d->m_isLocal = true;
-    d->m_serverUrl = serverUrl;
+    recordData(QmlServerUrl, serverUrl);
+}
+
+QUrl QmlProfilerRunner::serverUrl() const
+{
+    QVariant recordedServer = recordedData(QmlServerUrl);
+    if (recordedServer.isValid())
+        return recordedServer.toUrl();
+    QTC_ASSERT(connection().is<UrlConnection>(), return QUrl());
+    return connection().as<UrlConnection>();
+}
+
+void QmlProfilerRunner::setAutoStart()
+{
+    d->m_isAutoStart = true;
     connect(&d->m_launcher, &ApplicationLauncher::appendMessage,
             this, &QmlProfilerRunner::appendMessage);
     connect(this, &QmlProfilerRunner::localRunnerStopped,
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
index beea00b51d6fc0c6ca5d33cfd775442aa1a0cc4c..e65b6ec2cf0e0c856d53f1f95673a7afa7c92451 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h
@@ -46,6 +46,7 @@ public:
     ~QmlProfilerRunner() override;
 
     void setServerUrl(const QUrl &serverUrl);
+    QUrl serverUrl() const;
 
     void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
 
@@ -53,6 +54,7 @@ public:
     void notifyRemoteSetupFailed(const QString &errorMessage);
     void cancelProcess();
     void notifyRemoteFinished();
+    void setAutoStart();
 
 signals:
     void localRunnerStarted();
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
index e59a58d8cf3be2a785d2df186038bfd3133ef3f3..4484b7d965d4ef321b74c3e9afdb3b273882f38c 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
@@ -90,6 +90,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
 
     auto runner = new QmlProfilerRunner(runControl);
     runner->setServerUrl(serverUrl);
+    runner->setAutoStart();
     return runControl;
 }
 
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index c7529101d6bdb1e5389f61465a321a2fbe50edb3..97fc6854cae974d72a9333a0ceea2a74c7a1b3fc 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -351,9 +351,8 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
     runWorker->registerProfilerStateManager(d->m_profilerState);
     QmlProfilerClientManager *clientManager = d->m_profilerConnections;
 
-    QTC_ASSERT(runWorker->connection().is<UrlConnection>(), return);
     // FIXME: Check that there's something sensible in sp.connParams
-    auto serverUrl = runWorker->connection().as<UrlConnection>();
+    auto serverUrl = runWorker->serverUrl();
     clientManager->setServerUrl(serverUrl);
     if (!serverUrl.path().isEmpty()) {
         // That's the local socket case.
diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp
index 739ce2e522523b5e1e115c430ed084da47642965..ccc6b309eef00331630af6c358cc51d419e5b859 100644
--- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp
+++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp
@@ -45,6 +45,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
 
 void LocalQmlProfilerRunnerTest::connectRunner(QmlProfilerRunner *runner)
 {
+    runner->setAutoStart();
     connect(runner, &QmlProfilerRunner::localRunnerStarted, this, [this] {
         QVERIFY(!running);
         ++runCount;
@@ -66,7 +67,6 @@ void LocalQmlProfilerRunnerTest::testRunner()
 
     rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
     rc->setRunnable(debuggee);
-    rc->setConnection(UrlConnection(serverUrl));
     auto runner = new QmlProfilerRunner(rc);
     runner->setServerUrl(serverUrl);
     connectRunner(runner);
@@ -89,7 +89,6 @@ void LocalQmlProfilerRunnerTest::testRunner1()
     delete rc;
     rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
     rc->setRunnable(debuggee);
-    rc->setConnection(serverUrl);
     auto runner = new QmlProfilerRunner(rc);
     runner->setServerUrl(serverUrl);
     connectRunner(runner);
@@ -108,7 +107,6 @@ void LocalQmlProfilerRunnerTest::testRunner2()
     serverUrl = UrlConnection::localHostAndFreePort();
     rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
     rc->setRunnable(debuggee);
-    rc->setConnection(serverUrl);
     auto runner = new QmlProfilerRunner(rc);
     runner->setServerUrl(serverUrl);
     connectRunner(runner);