COAP-SERVER(5)
πΈ COAP-SERVER(5) πΈ
okay so welcome to the coap-server manual, bestie π this is the CoAP Server based on libcoap and we are going to get into every single flag without losing a crumb. no cap, all the details are staying. π«Ά
β¨ NAME β¨
Meet the whole squad:
coap-servercoap-server-gnutlscoap-server-mbedtlscoap-server-opensslcoap-server-notls
they are all CoAP Server based on libcoap. periodt. π
π¦ SYNOPSIS π¦
coap-server [-a priority] [-b max_block_size] [-d max] [-e] [-f
scheme://addr[:port] [-g group] [-l loss] [-p port] [-q
tls_engine_conf_file] [-r] [-t] [-v num] [-w [port][,secure_port]] [-A
address] [-E oscore_conf_file[,seq_file]] [-G group_if] [-L value] [-N]
[-P scheme://addr[:port],[name1[,name2..]]] [-T max_token_size] [-U
type] [-V num] [-X size] [[-h hint] [-i match_identity_file] [-k key]
[-s match_psk_sni_file] [-u user] [-2]] [[-c certfile] [-j keyfile] [-n]
[-C cafile] [-J pkcs11_pin] [-M rpk_file] [-R trust_casfile] [-S
match_pki_sni_file]]
for coap-server versions that use libcoap compiled for different (D)TLS libraries, you might also see coap-server-notls, coap-server-gnutls, coap-server-openssl, coap-server-mbedtls or coap-server-tinydtls available. otherwise, coap-server uses the default libcoap (D)TLS support. slay. β¨
π DESCRIPTION π
coap-server is the example server for the Constrained Application Protocol (RFC 7252). thatβs the whole vibe check, bestie. π¦
πΈ OPTIONS - GENERAL πΈ
-a priorityβ send logging output to syslog atprioritylevel, and that level is 0-7. cute and numeric. π-b max_block_sizeβ the maximum block size the server supports, in bytes. the valid glow-up values are16,32,64,128,256,512or1024. π-d maxβ enable support for creating dynamic resources when someone does aPUT, up to a limit ofmax. ifmaxis reached, a4.06code is returned until one of the dynamic resources has been deleted. so yes, thereβs a whole little resource economy happening. π-eβ echo back the data sent with aPUT. itβs giving βsay it back.β π«Ά-f scheme://address[:port]β act as a reverse proxy wherescheme,addressand the optionalportdefine how to connect to the internal server.schemeis one ofcoap,coaps,coap+tcp,coaps+tcp,coap+ws, andcoaps+ws.http(s)is not currently supported. this option can be repeated to provide multiple internal servers that are round-robin load balanced. obsessed with a balanced roster. π-g groupβ join the specified multicastgroupon start up. note: DTLS over multicast is not currently supported. sad but true. π-l listβ fail to send some datagrams specified by a comma separatedlistof numbers or number ranges. this is debugging only. iykyk. π₯-l loss%β randomly fail to send datagrams with the specified probability.100%means all datagrams fail,0%means no datagrams fail. this is also debugging only. dramatic but on purpose. π-p portβ theporton the given address will be listening for incoming connections. if (D)TLS is supported, thenport + 1will also be listened on for (D)TLS connections. the default port is5683if not given any other value. iconic default behavior. π-q tls_engine_conf_fileβtls_engine_conf_filecontains TLS ENGINE configuration. only OpenSSL is currently supported. seecoap-tls-engine-conf(5)for definitions. periodt. π-rβ enable multicast per resource support. if enabled, only/,/asyncand/.well-known/coreare enabled for multicast requests support; otherwise all resources are enabled. pick your multicast main characters wisely. π-tβ track resourceβs observe values so observe subscriptions can be maintained over a server restart. note: usekill SIGUSR2 <pid>for controlled shutdown. bestie, write that down. π«Ά-v numβ the verbosity level to use for general CoAP logging. default is4, maximum is8. loud and proud. π₯-w [port][,secure_port]β enable WebSockets support onport(WS) and/orsecure_port(WSS), comma separated. secure and non-secure can absolutely coexist. π-A addressβ the localaddressof the interface which the server has to listen on. very βbe where you say youβll beβ of it. π¦-E oscore_conf_file[,seq_file]βoscore_conf_filecontains OSCORE configuration. seecoap-oscore-conf(5)for definitions. the optionalseq_file(which is created if needed) is used to save the current transmit sequence number, so on server restart sequence numbers continue to increase and are not reset, preventing anti-replay mechanisms from being triggered. no resetting the timeline, bestie. β³-G group_ifβ use this interface for listening for the multicast group. this can be different from the implied interface if the-Aoption is used. interface multitasking. π-L valueβ sum of one or moreCOAP_BLOCK_*flag values for different block handling methods. default is1(COAP_BLOCK_USE_LIBCOAP). the flag lineup is:COAP_BLOCK_USE_LIBCOAPβ1COAP_BLOCK_SINGLE_BODYβ2COAP_BLOCK_TRY_Q_BLOCKβ4COAP_BLOCK_STLESS_BLOCK2β64COAP_BLOCK_NOT_RANDOM_BLOCK1β128
yes, STLESS is exactly how itβs written. we respect the spelling. π
-Nβ send NON-confirmable message for "observe" responses. if option-Nis not specified, a confirmable response will be sent. even if set, every fifth response will still be sent as a confirmable response (RFC 7641 requirement). the fifth one said βnot me being confirmable.β π-P scheme://address[:port],[name1[,name2[,name3..]]]βscheme,addressand optionalportfor how to connect to the next proxy server, plus zero or morenames(comma separated) that this proxy server is known by. the,(comma) is required. if there is noname1or if the hostname of the incoming proxy request matches one of these names, then this server is considered to be the final endpoint. ifscheme://address[:port]is not defined before the leading,(comma) of the first name, then the ongoing connection will be a direct connection.schemeis one ofcoap,coaps,coap+tcp,coaps+tcp,coap+ws, andcoaps+ws.httpandhttpsare not currently supported. this option can be repeated to provide multiple upstream servers that are round-robin load balanced. very βtag ur proxy besties.β π«Ά-T max_token_sizeβ set the maximum token length. valid range is8-65804. big token energy. π-U typeβ treat the address defined by-Aas a Unix socket address.typeiscoap(using datagram),coap+tcp(using stream),coaps(DTLS using datagram) orcoaps+tcp(TLS using stream). choose your transport, bestie. π-V numβ the verbosity level to use for (D)TLS library logging. default is3, maximum is7. secure but chatty. π₯-X sizeβ maximum message size to use for TCP based connections. default is8388864. maximum value is2^32 -1. enormous. iconic. slay. π
π OPTIONS - PSK π
(If supported by underlying (D)TLS library) β okay so keep that in mind, bestie. π
-h hintβ Identity Hint to send. default isCoAP. zero length is no hint. no hint, no problem. π¦-i match_identiity_fileβ this is a file that contains one or more lines of Identity Hints and (user) Identities to match for a different new Pre-Shared Key (PSK) (comma separated) to be used. e.g., per line:
hint_to_match,identity_to_match,use_key
a line that starts with # is treated as a comment. note: -k still needs to be defined for the default case. note: a match using the -s option may mean that the current Identity Hint is different to that defined by -h. matchmaking but for keys. π
-k keyβ Pre-shared key to use for inbound connections. this cannot be empty if defined. if the key begins with0x, then the hex text (two[0-9a-f]per byte) is converted to binary data. note: if-c cafileis defined, you need to define-k keyas well to have the server support both PSK and PKI. both, not either-or. π«Ά-s match_psk_sni_fileβ this is a file that contains one or more lines of received Subject Name Identifier (SNI) to match to use a different Identity Hint and associated Pre-Shared Key (PSK) (comma separated) instead of the-h hintand-k keyoptions. e.g., per line:
sni_to_match,use_hint,with_key
note: -k key still needs to be defined for the default case if there is not a match. note: the associated Pre-Shared Key will get updated if there is also a -i match. the update checking order is -s followed by -i. order matters, bestie. β
-u userβ user identity for pre-shared key mode (only used if option-Pis set). very situational, very valid. π-2β use EC-JPAKE negotiation (if supported). fancy negotiation behavior. π
π OPTIONS - PKI π
(If supported by underlying (D)TLS library) β again, keep that in your notes. π
note: if any one of certfile, keyfile or cafile is in PKCS11 URI naming format (pkcs11: prefix), then any remaining non PKCS11 URI file definitions have to be in DER, not PEM, format. otherwise all of certfile, keyfile or cafile are in PEM format. no mixing and matching without consequences. π«Ά
-c certfileβ PEM file or PKCS11 URI for the certificate. the private key can also be in the PEM file, or has the same PKCS11 URI. if not, the private key is defined by-j keyfile. note: if-k keyis defined, you need to define-c certfileas well to have the server support both PSK and PKI. π-j keyfileβ PEM file or PKCS11 URI for the private key for the certificate in-c certfileif the parameter is different fromcertfilein-c certfile. very βsame but separateβ of it. π-nβ disable remote peer certificate checking. this gives clients the ability to use PKI, but without any defined certificates. lowkey chaotic, but thatβs what it says. π-C cafileβ PEM file or PKCS11 URI that contains a list of one or more CAs that are to be passed to the client for the client to determine what client certificate to use. normally, this list of CAs would be the root CA and any intermediate CAs. ideally the server certificate should be signed by the same CA so that mutual authentication can take place. the contents ofcafileare added to the trusted store of root CAs. using the-Cor-Roptions will trigger the validation of the client certificate unless overridden by the-noption. trust chain drama, but make it secure. π₯-J pkcs11_pinβ the user pin to unlock access to the PKCS11 token. unlock the token, bestie. πβ¨-M(shown asrpk_filein the synopsis) β Raw Public Key (RPK) PEM file or PKCS11 URI that contains both PUBLIC KEY and PRIVATE KEY or just EC PRIVATE KEY. (GnuTLS and TinyDTLS(PEM) support only).-C cafileor-R trust_casfileare not required. raw key energy. π-R trust_casfileβ PEM file containing the set of trusted root CAs that are to be used to validate the client certificate. alternatively, this can point to a directory containing a set of CA PEM files. the-C cafileCA does not have to be in this list and is trusted for the validation. using-R trust_casfiledisables common CA mutual authentication, which can only be done by using-C cafile. using the-Cor-Roptions will trigger the validation of the client certificate unless overridden by the-noption. very βchoose your trust circleβ behavior. π-S match_pki_sni_fileβ this option denotes a file that contains one or more lines of Subject Name Identifier (SNI) to match for new certificate File and new CA File (comma separated) to be used. e.g., entry per line:
sni_to_match,new_cert_file,new_ca_file
a line that starts with # is treated as a comment. note: -c certfile and -C cafile still needs to be defined for the default case. okay bestie, thatβs the PKI section holding it down. π
β¨ EXAMPLES β¨
okay bestie, real talk β these are the glow-up examples, the ones you're actually gonna type π
- Example
coap-server -A ::1
Let the server listen on localhost (port 5683) for UDP/TCP. that's it. that's the whole vibe πΈ
- Example
coap-server -A ::1 -k mysecretKey -h myhint
Let the server listen on localhost (port 5683 for UDP/TCP and port 5684 for DTLS/TLS) with the server set up for PSK authentication if the client uses coaps:// or coaps+tcp://. so like, secure mode unlocked πβ¨
- Example
coap-server -A ::1 -k mysecretKey -h myhint -p 13011
The same, except the UDP/TCP listening port is 13011 and the DTLS/TLS listening port is 13012 (and not the default ports 5683 and 5684). moving day, new ports, same energy π
- Example
coap-server -A 2001:db8:81a8:0:6ef0:dead:feed:beef -v 5
The listening address is set to 2001:db8:81a8:0:6ef0:dead:feed:beef and the verbosity level is set to 5. the address is literally eating, no cap π
- Example
coap-server -A 2001:db8:81a8:0:6ef0:dead:feed:beef -g FF02::FD
Set listening address to 2001:db8:81a8:0:6ef0:dead:feed:beef and join the All CoAP Nodes multicast group FF02::FD. it's giving "we're in the group chat now" π«Ά
- Example
coap-server -P, -A ::1
Let the server listen on localhost (port 5683) for UDP/TCP, as well as accept any CoAP proxy requests and directly respond to them. main character proxy energy fr fr π«
- Example
coap-server -P coap://upstream-proxy, -A ::1
Let the server listen on localhost (port 5683) for UDP/TCP, and then open an upstream coap session to upstream-proxy for proxying onwards the CoAP client's request. passing the message along like a loyal bestie π¦
π FILES π
There are no configuration files.
so yes bestie β nothing to edit, nothing to lose, no config file to ghost you. iconic minimalism π
πͺ EXIT STATUS πͺ
0β Success. slay, it worked β¨1β Failure (syntax or usage error; configuration error; document processing failure; unexpected error). π the full sadness combo, don't take it personally
π SEE ALSO π
coap-client(5) and coap-oscore-conf(5) β go read the whole friend group, iykyk π
π BUGS π
Please raise an issue on GitHub at https://github.com/obgm/libcoap/issues to report any bugs.
Please raise a Pull Request at https://github.com/obgm/libcoap/pulls for any fixes.
like genuinely, if something's cursed, tell them β bug reports are self-care and PRs are a love language π§ββοΈ
π AUTHORS π
The libcoap project <libcoap-developers@lists.sourceforge.net>
alright bestie, that's the whole page π this was coap-server 4.3.5, dated 08/24/2026, and it's literally COAP-SERVER(5) β go forth, run your server, and remember: verbosity level 5 is a personality trait π
π₯
π¦ where this page comes from
- ubuntu stonking: libcoap3-bin 4.3.5-4ubuntu1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms