On my VPS server I'm trying to smtp but its not connecting

root@server1:~# telnet smtp.gmail.com 587
Trying port_number...
Trying port_number...
Trying ipv4_address...
telnet: Unable to connect to remote host: Cannot assign requested 

After some time its returning error.

But when I'm trying to ping on smtp.gmail.com its working

    root@server1:~# ping smtp.gmail.com
    PING gmail-smtp-msa.l.google.com ( 56(84) bytes of data.
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=1 ttl=44 time=7.45 ms
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=2 ttl=44 time=7.43 ms
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=3 ttl=44 time=7.43 ms
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=4 ttl=44 time=7.41 ms
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=5 ttl=44 time=7.41 ms
    64 bytes from oj-in-f108.1e100.net (port): icmp_seq=6 ttl=44 time=7.45 ms

What I am missing in my server configuration?

closed as off-topic by Jenny D says Reinstate Monica, peterh says reinstate Monica, Ward - Reinstate Monica, womble Sep 7 '17 at 4:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • Which hosting provider do you use? Google Cloud? – dkokmadis Aug 29 '17 at 11:28
  • could be something related to firewalls – Federico Galli Aug 29 '17 at 14:49
  • Extend your question with an iptables-save output. – peterh says reinstate Monica Aug 30 '17 at 13:20

This error means telnet cannot open local (!!!) port for connecting to the gmail tcp port.

Please check if this sas something useful for you: https://stackoverflow.com/questions/7640619/cannot-assign-requested-address-possible-causes

If telnet to http or anything else doesn't work either then the problem may be your kernel / sysctl configuration and nothing to do with gmail or smtp.

Not the answer you're looking for? Browse other questions tagged or ask your own question.