diff --git a/src/tunnel.c b/src/tunnel.c
index 4e95b3ec188202158cd51f3cc7010d366ef25133..f0ce98843538bfe7ede107ff2e784d45d3e8a780 100644
--- a/src/tunnel.c
+++ b/src/tunnel.c
@@ -459,6 +459,7 @@ static int tcp_connect(struct tunnel *tunnel)
 	return handle;
 
 err_connect:
+	free(env_proxy); // we have copied the string
 	close(handle);
 err_socket:
 	return -1;