diff --git a/runtime/pgAdmin4.cpp b/runtime/pgAdmin4.cpp
index bb78088..a419de4 100644
--- a/runtime/pgAdmin4.cpp
+++ b/runtime/pgAdmin4.cpp
@@ -237,7 +237,6 @@ int main(int argc, char * argv[])
             exit(1);
         }
 
-        QObject::connect(server, SIGNAL(finished()), server, SLOT(deleteLater()));
         server->start();
 
         // This is a hack to give the server a chance to start and potentially fail. As
@@ -290,7 +289,7 @@ int main(int argc, char * argv[])
             done = true;
     }
 
-
+    QObject::connect(server, SIGNAL(finished()), server, SLOT(deleteLater()));
     // Generate the app server URL
     QString appServerUrl = QString("http://127.0.0.1:%1/?key=%2").arg(port).arg(key);
 
