diff --git a/geomagio/api/ws/data.py b/geomagio/api/ws/data.py
index 2592daa49d12181c95555f1ae42ffc682a99b172..873de6db15d8cb305ee12ae469a5f9ac26e96406 100644
--- a/geomagio/api/ws/data.py
+++ b/geomagio/api/ws/data.py
@@ -35,9 +35,13 @@ def get_data_factory(
         SamplingPeriod.HOUR,
         SamplingPeriod.DAY,
     ]:
-        return MiniSeedFactory(host=host, port=os.getenv("DATA_MINISEED_PORT", "2061"))
+        return MiniSeedFactory(
+            host=host, port=int(os.getenv("DATA_MINISEED_PORT", "2061"))
+        )
     elif sampling_period in [SamplingPeriod.SECOND, SamplingPeriod.MINUTE]:
-        return EdgeFactory(host=host, port=os.getenv("DATA_EARTHWORM_PORT", "2060"))
+        return EdgeFactory(
+            host=host, port=int(os.getenv("DATA_EARTHWORM_PORT", "2060"))
+        )
     else:
         return None