diff --git a/smartgears/dataminer_app/templates/wps-config-fixer.j2 b/smartgears/dataminer_app/templates/wps-config-fixer.j2
index 1ef8dd1a..a9b7cfef 100644
--- a/smartgears/dataminer_app/templates/wps-config-fixer.j2
+++ b/smartgears/dataminer_app/templates/wps-config-fixer.j2
@@ -4,7 +4,11 @@
 WPS_CONFIG_FILE='{{ smartgears_instance_path }}/webapps/{{ dataminer_wps_name }}/config/wps_config.xml'
 
 # Fix the hostname
+{% if hostname is defined %}
+sed -Ei 's/hostname=\".*\"\ hostport/hostname="{{ hostname }}" hostport/' $WPS_CONFIG_FILE
+{% else %}
 sed -Ei 's/hostname=\".*\"\ hostport/hostname="{{ smartgears_hostname }}" hostport/' $WPS_CONFIG_FILE
+{% endif %}
 
 # Fix the port
 {%if setup_nginx %}