Curl error : No route to host

no route to host windows
no route to host centos 7
no route to host but can ping
no route to host port forwarding
no route to host vs connection refused
connect: no route to host docker
no route to host ssh
no route to host mac

So we're building a web application in PHP and we're trying to make requests to an external API. Problem is that we're getting a curl error:

cURL error 7: Failed to connect to external.api.com port 443: No route to host

A little bit of background now.

  • We're making requests using Guzzle.
  • We're hosting on Apache, which is running on a Linux machine and we're also using SSL.
  • The API is also using SSL, therefore the port 443 in error message.
  • The HTTP requests include a certificate for authentication.

I've managed to get it running on two different development environments but not on the production one. I suspect the problem is in the configuration of Apache, as if we haven't made it available to make requests to certain IP or port. I have no idea how to check it. I've read that I might have to change the file /etc/network/interface yet I haven't found any info on what to write there.

I've also read I have to run $ netstat -rn for answers yet I'm not sure what to look there.

EDIT:

Can't even make a simple get request without any parameters and anything. Yet I can make requests to https://google.com and https://facebook.com. Will write more in a few.

netstat -aln | grep 443 will show if your webserver is listening on that port.

Depending on which webserver you have installed your configuration file, for the site will be at /etc/nginx/sites-available/default, /etc/nginx/sites-available/yourSite, /etc/nginx/nginx.conf or some other similar paths for apache.

Wherever it is located, your configuration file should contain something like the following:

server {
listen 80;
listen 443 ssl;
server_name yourSite.com;
root "/path/to/yourSite";

index index.html index.htm index.php;

charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /path/to/webserver/youSite.error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

location ~ /\.ht {
    deny all;
}

ssl_certificate     /path/to/yourSite.crt;
ssl_certificate_key /path/to/yourSite.key;
}

After changing this file make sure to sudo service nginx reload or sudo service nginx restart (or the relative apache command).

sudo service nginx configtest or sudo nginx -t will help with debugging the config file.

How to Fix "No route to host" SSH Error in Linux, SSH No Route to Host Error. There are different reasons why this error appears. The first is normally that the remote server could be down,� I have no idea how to check it. I’ve read that I might have to change the file /etc/network/interface yet I haven’t found any info on what to write there. I’ve also read I have to run $ netstat -rn for answers yet I’m not sure what to look there.

After a lot of debugging and testing all of my code I contacted the service, whose API I was trying to consume.

They were an European service provider and they had whitelisted European IP's. Our production server was in the USA and after they whitelisted our IP, everything worked.

How do I fix a "No route to host" error?, There are a few reasons you could be seeing this error when trying to login with SSH. The first thing we would want to check is whether your� SSH No Route to Host Error There are different reasons why this error appears. The first is normally that the remote server could be down, so you need to check whether it is up and running using the ping command. # ping 192.168.56.100

today I hava face up the same question, like that I use curl http://localhost:8080 to check my tomcat can work or not

And it's error Failed to connect to ::1: No route to host

Finally I hava solve it.Obviously, it's the problem of your Apache tomcat. So you must check your logs firstly. If you found your port was used, find that course and kill it. Then restart your tomcat.

find the course by port: netstan -lnp | grep port kill course: kill -9 ****

curl "No route to host" or "Connection timed out" but python httplib , When I try to perform simple get request with curl like this curl 192.168.0.4:8080 from the host, I get No route to host error message. But if I perform the same� After running a traceroute on the nextcloud host to the office.XXX.XX DNS name found out it returned a wrong IP adress. Turned out there was a line in /etc/hosts from previous attempts to get onlyoffice running.

"Connection refused" vs "No route to host", On the other hand, when I try the same from another computer in the same network, I get a different error "No route to host": [erelsgl@erel-biu ~]$ wget http:// 132.70� Active 1 year, 11 months ago. Viewed 8k times. 1. I just configured a new server from DigitalOcean. I don't think I changed anything on the server's networking configuration other than changing the ssh port from 22 to 2202, but all of a sudden I am unable to ssh into the server. I was able to intially login a couple times with ssh on port 2202.

"cURL: no route to host" � Issue #1196 � lando/lando � GitHub, On Lando, I get a cURL error: cURL error 7: Failed to connect to webservice. internalsite.com port 80: No route to host. I think this is because it� critical backup failure: aba1009 curl error: https://x.x.x.x:25568/backup: http code: 400 (bad request) response: 'a backup is currently in progress.' – backup

Getting "No route to host." while my system can route to host � Issue , I didn't know the first syntax was supported, but yes same error. You will get "no route to host" if the port is closed, even if the host responds to ICMP ping. root @zap:~# curl 172.83.40.112 curl: (52) Empty reply from server. After a lot of debugging and testing all of my code I contacted the service, whose API I was trying to consume. They were an European service provider and they had whitelisted European IP's.

Comments
  • This is usually a firewall problem. Some corporate environments will even block outbound traffic in production zones.
  • @JeffPuckettII $ sudo ufw status returns inactive.