Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

freeport

> 编程语言
Open source

Get a free and open tcp port that is ready to use

370 stars0 likes1 views
WebsiteGitHub

About

Get a free and open tcp port that is ready to use

FreePort

Get a free open TCP port that is ready to use.

Command Line Example:

bash
# Ask the kernel to give us an open port.
export port=$(freeport)

# Start standalone httpd server for testing
httpd -X -c "Listen $port" &

# Curl local server on the selected port
curl localhost:$port

Golang example:

go
package main

import "github.com/phayes/freeport"

func main() {
	port, err := freeport.GetFreePort()
	if err != nil {
		log.Fatal(err)
	}
	// port is ready to listen on
}

Installation

Mac OSX

bash
brew install phayes/repo/freeport

CentOS and other RPM based systems

bash
wget https://github.com/phayes/freeport/releases/download/1.0.2/freeport_1.0.2_linux_386.rpm
rpm -Uvh freeport_1.0.2_linux_386.rpm

Ubuntu and other DEB based systems

bash
wget wget https://github.com/phayes/freeport/releases/download/1.0.2/freeport_1.0.2_linux_amd64.deb
dpkg -i freeport_1.0.2_linux_amd64.deb

Building From Source

bash
sudo apt-get install golang                    # Download go. Alternativly build from source: https://golang.org/doc/install/source
go get github.com/phayes/freeport

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言