The reason this does not work is because container networks are completely isolated which means the server and runner are on completely separate networks. This means localhost refers to the network inside the runner container; the server is not running inside the runner container which is why you cannot use localhost to connect.
thank you for your response. I used ngrok for configuring runner and server in the local machine. now it is running fine and runner is able to ping the server