# UDP Service not working (following docs)

**URL:** <https://community.fly.io/t/udp-service-not-working-following-docs/20034>\
**Category:** General\
**Tags:** machines, proxy, login-only\
**Created:** [May 24, 2024, 3:47pm UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034 "2024-05-24T15:47:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyubchev](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/lyubchev/32/36184_2.png) [@lyubchev](https://community.fly.io/u/lyubchev)\
**Post date:** [May 24, 2024, 3:47pm UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034/1 "2024-05-24T15:47:09Z")

</div>

I’ve followed the docs which help with setting up a UDP service and deploying it given the provided [github repo](https://github.com/fly-apps/udp-echo-). Fortunately so far, everything looked fined and I was able to perform the test with netcat (`echo "hello world" | nc -w1 -u *.fly.dev 5000`) and got “hello world” back. When I tried with my own coap server it wouldn’t be reachable by my client. I can’t seem to find out why.

I did bind on the `fly-global-services` and also opt-in for a dedicated ipv4.

fly.toml

```toml
app = 'snitch-server'
primary_region = 'ams'

[[services]]
auto_start_machines = true
auto_stop_machines = true
internal_port = 5000
min_machines_running = 0
protocol = "udp"

[[services.ports]]
port = 5000

[[vm]]
cpu_kind = 'shared'
cpus = 1
memory = '1gb'

```

Dockerfile:

```dockerfile
FROM golang:1.22-alpine as build

WORKDIR /app
COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN go build -o coap-server ./cmd/coap-server

FROM alpine:latest
WORKDIR /app

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /app/coap-server /app

CMD ["./coap-server"]

```

go server:

```go
func main() {
	r := mux.NewRouter()
	r.Handle("/a", mux.HandlerFunc(handleA))
	r.Handle("/b", mux.HandlerFunc(handleB))

	go func() {
		log.Fatal(coap.ListenAndServe("udp", "fly-global-services:5000", r))
	}()
	log.Println("🫡 Listening for a coap message on port 5688")
	select {}
}

```

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [May 24, 2024, 4:28pm UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034/2 "2024-05-24T16:28:45Z")

</div>

> [@lyubchev](#):
>
> `auto_stop_machines = true`

Hi… This line might be the problem. Last I heard, auto-start was [not actually supported](https://community.fly.io/t/machines-first-impressions/5571/9) for UDP, 🐉.

Hope this helps a little!

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [May 24, 2024, 4:29pm UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034/3 "2024-05-24T16:29:48Z")

</div>

Added #machines, #proxy

---

<div class="post-metadata">

**Author:** ![lyubchev](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/lyubchev/32/36184_2.png) [@lyubchev](https://community.fly.io/u/lyubchev)\
**Post date:** [May 27, 2024, 8:53am UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034/4 "2024-05-27T08:53:46Z")

</div>

Tried it today, but didn’t detect any change of behavior.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [June 3, 2024, 8:54am UTC](https://community.fly.io/t/udp-service-not-working-following-docs/20034/5 "2024-06-03T08:54:16Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
