Mongoose LogoMongoose

Full-stack embeddednetworking library

Mongoose is a full-stack embedded networking library for C/C++: a TCP/IP stack with drivers, TLS 1.3, an embedded web server (HTTP, WebSocket), MQTT and firmware OTA updates in two files, mongoose.c and mongoose.h. Mongoose runs on STM32, NXP and other microcontrollers, on bare metal or with an RTOS, with no external dependencies. Use it for cloud connectivity, device web dashboards, secure firmware updates and remote control.

Siemens logo Bosch logo Schneider Electric logo Samsung logo Broadcom logo Pilz logo Google logo

What's in mongoose.c

Networking modules amalgamated into one file, with everything a device needs for typical tasks. Mongoose has been in production since 2004, is under continuous security review, and is used by hundreds of companies, including NASA on the International Space Station.

Embedded TCP/IP stack

// Built-in stack and driver
#define MG_ENABLE_TCPIP 1
#define MG_ENABLE_DRIVER_STM32H 1

Dual IPv4/IPv6 stack. Built-in drivers for STM32, NXP i.MX RT, RW612 and RP2350. Or run on top of lwIP or Zephyr.

Built-in TLS 1.3

#define MG_TLS MG_TLS_BUILTIN
// MG_TLS_MBED    to use mbedTLS
// MG_TLS_WOLFSSL to use WolfSSL
// MG_TLS_OPENSSL to use OpenSSL

HTTPS, WSS are built-in. Mutual TLS supported. TLS takes +50Kb flash, +10 Kb RAM per connection. Fast sub-100ms handshakes on ARM

Embedded web server

mg_http_listen(&mgr, "http://0.0.0.0:80", fn, NULL);,

// In fn(), on MG_EV_HTTP_MSG:
mg_http_reply(c, 200, "", "Hello\n");

HTTP server and client. REST APIs, static files from an embedded filesystem, file uploads, JWT auth, firmware OTA updates.

WebSocket

// In fn(), on MG_EV_HTTP_MSG:
mg_ws_upgrade(c, hm, NULL);

// Later, push data to the browser:
mg_ws_send(c, "hello", 5, WEBSOCKET_OP_TEXT);

Server and client, plain or over TLS. Push live data to a browser or a cloud service over one connection. Over 25k msgs/sec on STM32H7!

MQTT client and server

mg_mqtt_connect(&mgr, "mqtts://broker:8883", &opts, fn, NULL);,

// In fn(), on MG_EV_MQTT_OPEN:
opts.topic = mg_str("dev1/status");
opts.message = mg_str("online");
mg_mqtt_pub(c, &opts);

MQTT 3.1.1 and 5, plain or over TLS. Guides for AWS IoT, Azure IoT Hub and EMQX.

Network services

long t = mg_json_get_long(json, "$.temp", 0);
mg_snprintf(buf, sizeof(buf), "{%m:%ld}",
            MG_ESC("temp"), t);

SNTP, DNS, mDNS, DNS-SD, Modbus-TCP server, JSON parser and printer, JSON-RPC, JWT. Raw TCP and UDP for custom protocols.

Firmware OTA updates

bool mg_ota_begin(size_t size);
bool mg_ota_write(const void *buf, size_t n);
bool mg_ota_end(void);

Streams straight to flash, checks ECDSA-P256 signatures, then swaps banks. STM32, ESP32, RP2040/RP2350, NXP, Renesas, WCH.

mDash device management

#define MG_ENABLE_MDASH 1
#define MG_MDASH_KEY "..."
#define MG_FIRMWARE_VERSION "myfw.1.0"

Cloud backend for fleet OTA updates, remote control and health monitoring. Enabled in mongoose_config.h. Managed at mdash.net or installed on your own servers.

Security and CRA

// Reject firmware without our signature
#define MG_OTA_PUBLIC_KEY { \
  0x19, 0x7f, 0xed, 0x81, 0x8b, 0xb7, \
  ...

Security reports come in every month and get fixed. Commercial users get fixes before CVEs go public. OTA updates have signature checks and authentication, as the EU CRA expects.

Security process and EU CRA compliance »

Device dashboard

Mongoose device dashboard running on a microcontroller

Dashboard API connects device data to a browser UI: realtime data display, setting panels, user auth, file uploads, firmware update. Write the UI by hand or with AI, or build it in Mongoose Wizard, a no-code builder that generates a ready-to-build project.

AI-assisted development

# AGENTS.md
- Read mongoose.h first.
- Use public APIs from mongoose.h only.
- Prefer existing examples over
  invented patterns.

The whole API, with docstrings and examples, is in mongoose.h and fits in one context window. AGENTS.md tells coding agents how to use it, llms.txt summarises Mongoose for LLMs.

One library means one small, coherent API instead of several unrelated ones. The docstrings live in the header, so AI tools need no separate MCP server and write better code on the first try.

Supported platforms

// mongoose_config.h
#define MG_ARCH MG_ARCH_CUBE
// or MG_ARCH_ZEPHYR, MG_ARCH_ESP32,
//    MG_ARCH_PICOSDK, MG_ARCH_UNIX

Bare metal, FreeRTOS, Zephyr, ThreadX, CMSIS-RTOS, RT-Thread, TI-RTOS, embedded Linux, Windows, macOS. Already on lwIP or Zephyr? Mongoose runs on top of it.

Supported platforms »

Customer testimonials

Mongoose has helped us to achieve the required level of performance with the seamless integration.

Santhosh Kumar P.B., Lead Architect, Schneider Electric

Mongoose is well documented, well supported, stable and full of features. The support and response time for any queries was outstanding.

Tony Gaunce, Principal Engineer, Broadcom

We have exclusively used the Mongoose web server since 2012 and we have never regretted that decision.

Joe Porthouse, Director of Engineering, Toptech Systems

Mongoose was the only product which fulfilled our requirements. Our experience was good enough to influence other development teams in Pilz to use Mongoose.

Frank Eberle, Software Developer, Pilz

Mongoose has become the standard across all our development areas. The Mongoose team’s professionalism, teamwork, and focus have enabled us to reach the next level.

Manuel Solano, Product Manager, Balluff

Everything just works, we faced no problems with Mongoose.

Samuel Remy, Project Engineer, HAENNI Instruments

More in case studies.

Licensing

Dual-licensed: GPLv2 and commercial.

GPLv2

For evaluation, prototypes and open-source products. Source, docs and examples on GitHub.

Many popular open-source projects use Mongoose, for example SWUpdate, the embedded Linux update framework.

Commercial

For closed-source firmware. Support comes directly from the engineers who wrote the whole stack from scratch, not a support desk. Early security fixes. We reply the same business day.

To explain Mongoose benefits to your management, use the business case PDF.

To get a 45-minute call with a Mongoose engineer, get your hardware ready and book a call.

FAQ

What is a full-stack embedded networking library?

A single library that covers every networking layer a connected device needs: network drivers, TCP/IP stack, TLS, application protocols such as HTTP, WebSocket and MQTT, and firmware OTA updates. Mongoose is a full-stack embedded networking library in two files, mongoose.c and mongoose.h.

Can I use Mongoose with lwIP?

Yes. Mongoose runs on top of lwIP with sockets enabled, and on Zephyr and other BSD socket stacks. Or replace lwIP with the Mongoose built-in TCP/IP stack, which has drivers for STM32, NXP i.MX RT, RW612 and RP2350.

Can I use Mongoose with mbedTLS?

Yes. Set MG_TLS to MG_TLS_MBED in mongoose_config.h. wolfSSL (MG_TLS_WOLFSSL) and OpenSSL (MG_TLS_OPENSSL) work the same way. Or use the built-in TLS stack and drop the external TLS library.

Does Mongoose support TLS 1.2 and TLS 1.3?

The built-in TLS stack implements TLS 1.3. For TLS 1.2, build Mongoose with mbedTLS, wolfSSL or OpenSSL.

How much flash and RAM does Mongoose take?

On a bare-metal STM32H723, the TCP/IP stack with an HTTP server takes about 36 KB of flash and 10 KB of RAM, plus about 1.6 KB of RAM per connection. With built-in TLS 1.3 it is about 82 KB of flash and about 14 KB of RAM per TLS connection.

STM32 TCP/IP footprint measurements »

Does Mongoose need an RTOS?

No. Mongoose is event-driven and single-threaded: one mg_mgr_poll() loop runs all connections, so it works on bare metal. It also runs under FreeRTOS, Zephyr, ThreadX, CMSIS-RTOS, RT-Thread and TI-RTOS.