Curl error : No route to host

It worked for me for apache (httpd)

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

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.


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.