diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c
index 3c0cfe72f7aab57de2a09cbba0d0ad0c81ab9088..c92d1dc1b06312dd3c55c71802b9e4b0cb393b1d 100644
--- a/extmod/modwebrepl.c
+++ b/extmod/modwebrepl.c
@@ -245,7 +245,11 @@ STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
     }
 
     if (self->data_to_recv != 0) {
-        static byte filebuf[512];
+        // Ports that don't have much available stack can make this filebuf static
+        #if MICROPY_PY_WEBREPL_STATIC_FILEBUF
+        static
+        #endif
+        byte filebuf[512];
         filebuf[0] = *(byte*)buf;
         mp_uint_t buf_sz = 1;
         if (--self->data_to_recv != 0) {
diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h
index 03be59b06321b0dd21d46b11c76df952724e0fa7..3bf82202829451f94682238cd009987774836362 100644
--- a/ports/esp8266/mpconfigport.h
+++ b/ports/esp8266/mpconfigport.h
@@ -90,6 +90,7 @@
 #define MICROPY_PY_UWEBSOCKET       (1)
 #define MICROPY_PY_WEBREPL          (1)
 #define MICROPY_PY_WEBREPL_DELAY    (20)
+#define MICROPY_PY_WEBREPL_STATIC_FILEBUF (1)
 #define MICROPY_PY_FRAMEBUF         (1)
 #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
 #define MICROPY_PY_OS_DUPTERM       (2)