diff --git a/.gitlab/ci_scripts/create_vps.sh b/.gitlab/ci_scripts/create_vps.sh
index 654963ada8c63111186579c718c2279e77d94eca..47ae61bd6ac3477d870e0e2c3eac81da08050a7d 100644
--- a/.gitlab/ci_scripts/create_vps.sh
+++ b/.gitlab/ci_scripts/create_vps.sh
@@ -2,6 +2,10 @@
 # Check if cluster directory was available from cache
 set -v
 
+# Shorten the hostname to work around a bug in cosmos, which fails to create a
+# working VPS if the the hostname is too long.
+HOSTNAME=$(expr substr "${HOSTNAME}" 1 40)
+
 if [ -d clusters/$HOSTNAME/secrets ]
 then
   ip_address=$(python -m openappstack ${HOSTNAME} info --ip-address)