You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Method 2: Use ss command (modern alternative to netstat)
73
+
"ss -tuln | grep -q ':$port '",
74
+
// Method 3: Use lsof if available
75
+
"lsof -i :$port >/dev/null 2>&1",
76
+
// Method 4: Use fuser if available
77
+
"fuser $port/tcp >/dev/null 2>&1",
78
+
];
79
+
80
+
$portInUse = false;
81
+
foreach ($commandsas$command) {
82
+
try {
83
+
instant_remote_process([$command], $server);
84
+
$portInUse = true;
85
+
break;
86
+
} catch (\Throwable$e) {
87
+
88
+
continue;
89
+
}
90
+
}
91
+
if ($portInUse) {
92
+
if ($fromUI) {
93
+
thrownew \Exception("Port $port is in use.<br>You must stop the process using this port.<br><br>Docs: <a target='_blank' class='dark:text-white hover:underline' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' class='dark:text-white hover:underline' href='https://coolify.io/discord'>https://coolify.io/discord</a>");
94
+
} else {
95
+
returnfalse;
96
+
}
97
+
}
98
+
}
71
99
try {
72
100
if ($server->proxyType() !== ProxyTypes::NONE->value) {
73
101
$proxyCompose = CheckConfiguration::run($server);
@@ -94,16 +122,6 @@ public function handle(Server $server, $fromUI = false): bool
94
122
if (count($portsToCheck) === 0) {
95
123
returnfalse;
96
124
}
97
-
foreach ($portsToCheckas$port) {
98
-
$connection = @fsockopen($ip, $port);
99
-
if (is_resource($connection) && fclose($connection)) {
100
-
if ($fromUI) {
101
-
thrownew \Exception("Port $port is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
0 commit comments