I am Hack Sparrow
Captain of the Internets.

Ionic app keeps running at localhost:8100

What happens

An Ionic app keeps running at http://localhost:8100 in a particular browser (very likely Chrome). It does not load in other browsers, neither can you curl nor telnet to it. You cannot find any process listening on TCP port 8100. You restart your computer, the app is still running!

Why it happened

You uncommented / enabled serviceWorker in your Ionic app. Particularly this piece of code:

<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(() => console.log('service worker installed'))
.catch(err => console.error('Error', err));
}
</script>

This installed a service worker in your browser, which is essentially an offline version of your Ionic, which will keep running in your browser whether the real ionic app is running or not.

How to fix it

Here is how to uninstall all service workers in the browser. Use the registration details to uninstall a particular service worker.

navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister()
} })

Conclusion

Now that you know what happens when you enable serviceWorker in your Ionic app, be sure you know what you are doing and read up more about     Service Workers.

Make a Comment