简体   繁体   中英

Unable to connect to AWS EC2 Instance - Connection Refused

I am new to AWS. I created a new AWS account and created an AWS Linux ESC2 instance and connected through SSH connection. I could run and install new libraries in python 3.7 as well. But then I tried to transfer a file to the instance using scp and since then I am not able to connect to the EC2 instance. This is the error I get:

OpenSSH_8.6p1, LibreSSL 2.8.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/../.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/../.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to ec2-{}.us-east-2.compute.amazonaws.com port 22.
ssh: connect to host ec2-{}.us-east-2.compute.amazonaws.com port 22: Connection refused

When I try to ping the server using this:

curl -XGET '{Public IPv4 address}:22'

I get the same error:

curl: (7) Failed to connect to {Public IPv4 address} port 22: Connection refused

I have already tried rebooting and restarting the instance and also I have already put my IP address in the inbound rules so that it is allowed but still I am not able to connect.

Any suggestions?

Possible reasons -

  • The host reached the instance but there was no service listening on the SSH port.
  • A firewall blocked and was set to reject the package instead of dropping it.

Possible resolutions -

  • Verify there isn't a firewall blocking the connection.
  • Verify the SSH service is running on the instance.
  • Verify the security group and network ACLs allow incoming traffic on TCP port 22.
  • Verify the SSH TCP port 22 is in the listening state.

For more details how to solve this problem, please take a look at this aws page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM