EOF from the docker daemon after setting proxy

I followed the steps in documentation to set proxy by creating a docker.service.d folder in systemd/system and http-proxy.conf file. But after that i am getting

"error response from daemon: get https://registry-1.docker.io/v2/: eof "

Version : Docker version 18.09.2, build 6247962
OS : Ubuntu 18.04 (4.15.0-20-generic)

without the proxy setting, I am able to login but when pulling images from hub i get this error :
error pulling image configuration: dial tcp connect: connection refused

Login However succeeds without setting proxy