diff --git a/contrib/codecs/init.go b/contrib/codecs/init.go
index 357c25960685f24689de30b6b14db0572c10f433..df52372b4b3efe0d857f84d37e1f2c0e212fb7c8 100644
--- a/contrib/codecs/init.go
+++ b/contrib/codecs/init.go
@@ -3,11 +3,10 @@ package codecs
 import (
 	"context"
 	"net"
+	gohttp "net/http"
 	"net/url"
 	"strings"
 
-	gohttp "net/http"
-
 	"gfx.cafe/open/jrpc/contrib/codecs/http"
 	"gfx.cafe/open/jrpc/contrib/codecs/rdwr"
 	"gfx.cafe/open/jrpc/contrib/codecs/websocket"
@@ -30,7 +29,7 @@ func init() {
 	}, "http+ws")
 
 	RegisterHandler(func(bind *url.URL, srv *server.Server, opts map[string]any) error {
-		tcpAddr, err := net.ResolveTCPAddr("tcp", bind.String())
+		tcpAddr, err := net.ResolveTCPAddr("tcp", bind.Host)
 		if err != nil {
 			return err
 		}
@@ -56,8 +55,12 @@ func init() {
 		return websocket.DialWebsocket(ctx, url, "")
 	}, "wss", "ws")
 
-	RegisterDialer(func(ctx context.Context, url string) (jsonrpc.Conn, error) {
-		tcpAddr, err := net.ResolveTCPAddr("tcp", url)
+	RegisterDialer(func(ctx context.Context, u string) (jsonrpc.Conn, error) {
+		pu, err := url.Parse(u)
+		if err != nil {
+			return nil, err
+		}
+		tcpAddr, err := net.ResolveTCPAddr("tcp", pu.Host)
 		if err != nil {
 			return nil, err
 		}