GeoServer OpenLayers preview always points to localhost:8080

The default GeoServer app engine / server is Jetty. In case you have not switched to the more powerful Tomcat, there is the procedure to change the port :

  • Shutdown Jetty server running $GEOSERVER/bin/shutdown.sh or $GEOSERVER/bin/shutdown.bat
  • Open file $GEOSERVER/etc/jetty.xml
  • Search line 8080 and change the default port.
  • Start Jetty

Here is my source for this procedure.

Edit : My answer was out of topic, so here is another one.

The preview function of GeoServer, using OpenLayers, is just a preview function, not a full featured OpenLayers application.

If you want to use the preview from distant client machines, you must log into the GeoServer administration and then go to preview. Just replace "locahost" with the IP address or DNS name of the server machine. If that don't work, your GeoServer installation could be broken, please provide details on the installation context (OS, versions).

If you want to consume your webservices from distant client machines, you should build an OpenLayers application with WMS/WFS layers connected to your GeoServer data feeds. See the examples on the OpenLayers doc.