Does SlashImage work on localhost or a staging site?

2 min read · Last updated June 2026

Yes. SlashImage works on localhost or a staging site, as long as that machine can reach the internet and your domain controls (if you set them up) allow the hostname. There is no special handling for localhost or staging - the service treats them like any other hostname.

Why it works off a live domain

When you optimize an image, your site sends the image itself out to api.slashimage.com and gets the smaller version back. The service never visits your URL, so your site does not need to be on a live public domain. Two things decide whether it works:

  • The machine must reach the internet. Optimization is an outgoing request to api.slashimage.com, so a fully offline computer fails with a connection error.
  • Domain controls, if set up, must allow the hostname. If you locked your key to specific domains, a request from a hostname that is not on the list is rejected - and localhost or a staging hostname has to be on the list. The plugin shows this as an invalid-key message even though the key is fine. To allow a staging or local site, add its hostname to your allowed domains. See lock your key to specific domains.

If it will not connect

If optimizing fails with a message about not reaching the service, like Could not connect to the optimization service. Your host may be blocking outbound requests., that is a connection problem, not a domain or key one - usually no outbound internet access on the machine. See Why can't SlashImage connect to the optimization service?.

See also

Was this helpful?