# How to deploy a Go app.

URL: https://antideploy.com/blog/how-to-deploy-a-go-app

A Go app deploys with one sentence. Antideploy builds the binary and runs it, and your code listens on PORT.

## At a glance

- **go.mod**: Detected from the file at the root
- **A built binary**: The build sets the entrypoint
- **PORT**: Read it, default 8080
- **DATABASE_URL**: Set for you with Postgres

Published 7 October 2026. Facts checked 7 October 2026. 2 min read.

## The short answer

To deploy a Go app, give your coding agent the sentence below. Antideploy finds `go.mod`, builds your program into one binary, and runs it. You do not write a start command. Your code must listen on the port in the `PORT` variable, and on all addresses. For Go projects, Antideploy uses port 8080.

> **Say this to your coding agent**
>
> Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

## What Antideploy detects

- **Go.** Detected from `go.mod` at the root of what you send.
- **The start command.** Antideploy does not add one. Go compiles to a single binary, and the build sets the entrypoint from what it produced.
- **The port.** It sends traffic to port 8080 and sets `PORT` to match.
- **The database.** If your code needs Postgres, Antideploy creates one and sets `DATABASE_URL` and the `PG*` variables.

## A small Go server

**main.go**

```
package main

import (
	"context"
	"fmt"
	"net/http"
	"os"

	"github.com/jackc/pgx/v5/pgxpool"
)

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
	if err != nil {
		panic(err)
	}
	defer pool.Close()

	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprint(w, "ok")
	})

	http.ListenAndServe(":"+port, nil)
}
```

Listening on `":" + port` means all addresses, which is what a server needs. Do not use `"localhost:" + port`.

## Step by step

### 1. Check the module

`go.mod` and `go.sum` are committed. Run `go mod tidy` if you added a package.

### 2. Paste the sentence and approve one link

Your agent creates the app, and a database if your code needs one, and writes the connection details into your `.env` without printing them.

### 3. Deploy and open the link

Antideploy builds the binary, starts it and checks that it answers. Your agent tells you the address.

## Common problems

- **go.sum is incomplete.** The build says `missing go.sum entry` or `updates to go.mod needed`. Run `go mod tidy` on your machine and commit `go.mod` and `go.sum`.
- **The program does not compile.** The deploy names the error, such as an undefined name.
- **The app never starts listening.** It uses a fixed port, or `localhost`. Read `PORT` and listen on all addresses. See [never started listening](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port).

## Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

### Apps sleep when idle

On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

### One instance, no previews

Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

### The disk forgets

Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

## Go questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Do I need a Dockerfile for Go?

No. Antideploy builds it from `go.mod`. If there is a Dockerfile at the root, it is used.

### Is Go free to host here?

It runs on the Free plan: 1 live app with a server and 1 Postgres database, with no card.

### Is the first request slow for Go?

Apps sleep when idle, and the first request after sleeping waits for the app to start. A compiled Go binary starts quickly, but we have not measured Go apps, so there is no number to give.

### Can I run background goroutines?

Yes, while the app is running. An idle app sleeps and stops them, so use a [scheduled job](https://antideploy.com/blog/how-to-run-a-scheduled-job-on-your-app) for work that must happen on a schedule.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to deploy a Spring Boot app](https://antideploy.com/blog/how-to-deploy-a-spring-boot-app): Maven or Gradle, the executable jar, the port, and a Postgres JDBC URL from the PG variables.
- [How to add a Postgres database to your app](https://antideploy.com/blog/how-to-add-a-postgres-database-to-your-app): Ask your agent. A Postgres 17 database is created beside your app and DATABASE_URL is set.
- [Your app built successfully but never started listening on its port](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port): The app built but never answered on its port. Read PORT, listen on 0.0.0.0 and check the logs.

- [Hosting](https://antideploy.com/platform/hosting)
- [Database](https://antideploy.com/platform/database)
- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Deployments](https://antideploy.com/platform/deployments)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
