Golang net.Listen binds to port that's already in use
问题 Port 8888 is already bound on my (OS X 10.13.5) system, by a process running inside a docker container: $ netstat -an | grep 8888 tcp6 0 0 ::1.8888 *.* LISTEN tcp4 0 0 *.8888 *.* LISTEN A python program which tries to bind to that port (using as close to the socket options of golang as I can manage), fails in the way I expect: import socket import fcntl import os def main(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) flag = fcntl.fcntl(sock.fileno(), fcntl.F_GETFL) fcntl.fcntl