Back to LanguageTool Homepage - Privacy - Imprint

Bad response (Integration On Websites)

Hi! I use example (
When I send request I receive ‘Error: couldn’t connect to host’
PHP - 5.5

Is your site accessible on the web? Then please post the URL and we could try to debug it.

Thanks for answer!
Problem is related to port (Our provider closed port 8081)

How exactly does your proxy.php script look like?

// LanguageTool Proxy Script
// requires curl for PHP - on Ubuntu, install with "sudo apt-get install php5-curl"

function shutdown($curl) {
  // close curl even if the script was aborted, see

  $postText = trim(file_get_contents('php://input'));
  $postText = html_entity_decode($postText, ENT_COMPAT, "UTF-8");
  $curl = curl_init();
  try {
    register_shutdown_function('shutdown', $curl);
    curl_setopt($curl, CURLOPT_URL, "");
    curl_setopt($curl, CURLOPT_PORT, 8081);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postText);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    if (isset($_SERVER['HTTP_REFERER'])) {
      curl_setopt($curl, CURLOPT_REFERER, $_SERVER['HTTP_REFERER']);
    $realIp = $_SERVER['REMOTE_ADDR'];
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-forwarded-for: $realIp"));
    header("Content-Type: text/xml; charset=utf-8");
    //for debugging:
    //header("Content-Type: text/plain");
    if (curl_exec($curl) === false) {
      $errorMessage = curl_error($curl);
      $errorCode = curl_errno($curl);
      if (!$errorMessage && $errorCode == 7) {
        // Actually the message can be empty, e.g. if the Apache server is in "No buffer space available" state...
        $errorMessage = "Could not connect LanguageTool server";   // source:
      print "Error: " . $errorMessage;
      error_log("proxy.php error: $errorMessage, code: $errorCode");
  } finally {
} else {
  print "Error: this proxy only supports POST requests";

So it seems couldn't connect to host means exactly that: your server cannot connect You could try logging into your server and call that URL with a command-line based browser like w3m or lynx. If that also doesn’t work, there’s maybe a Firewall that prevents access.