diff --git a/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java b/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
index 4b92eeafaaa0b54a003a4ffaa5a4b0defdbcb041..291620a5ead271ae780f733e9d39551623168a1d 100644
--- a/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
+++ b/src/main/java/net/floodlightcontroller/statistics/web/BandwidthResource.java
@@ -69,6 +69,9 @@ public class BandwidthResource extends ServerResource {
                 spbs = new HashSet<SwitchPortBandwidth>();
                 //fix concurrency scenario
                 IOFSwitch sw = switchService.getSwitch(dpid);
+                if (sw == null){
+                		return Collections.singletonMap("ERROR", "Switch was not online: " + dpid);
+                }
                 for (OFPortDesc pd : sw.getPorts()) { /* do specific DPID; do all ports */
                     SwitchPortBandwidth spb = statisticsService.getBandwidthConsumption(dpid, pd.getPortNo());
                     if (spb != null) {