Connection to apache server refused
===

i know that there are similar questions on Stackoverflow, but they did not solve my problem. I want to upload a file from android to a local apache server, but gain a 'connection refused' error. 

I'am using a physical device with Android 3.2 and MAMP on Mac OS X Lion (Apache on Port 80). I also added the INTERNET permission to the manifest. 

Here is the code:

        String lineEnd = "\r\n";
		String twoHyphens = "--";
		String boundary = "*****";

		FileInputStream fileInputStream = null;
		try {
			fileInputStream = new FileInputStream(new File(
					"/mnt/sdcard/somefile.xml"));
		} catch (FileNotFoundException e) {
			...
		}

		URL url = null;
		try {
			url = new URL("http://192.168.x.xxx:80/index.php");
		} catch (MalformedURLException e) {
			...
		}

		try {
			// Open a HTTP connection to the URL
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();

			// Allow Inputs
			conn.setDoInput(true);
			// Allow Outputs
			conn.setDoOutput(true);

			// Don't use a cached copy.
			conn.setUseCaches(false);

			// Use a post method.
			conn.setRequestMethod("POST");

			conn.setRequestProperty("Connection", "Keep-Alive");
		
			conn.setRequestProperty("Content-Type",
					"multipart/form-data;boundary=" + boundary);

			DataOutputStream dos = new DataOutputStream(conn.getOutputStream());

			dos.writeBytes(twoHyphens + boundary + lineEnd);
			dos.writeBytes("Content-Disposition: post-data; name=uploadedfile;filename="
					+ SOMEFILE + "" + lineEnd);
			dos.writeBytes(lineEnd);

			// create a buffer of maximum size
			int bytesAvailable = fileInputStream.available();
			int maxBufferSize = 1000;
			// int bufferSize = Math.min(bytesAvailable, maxBufferSize);
			byte[] buffer = new byte[bytesAvailable];

			// read file and write it into form...
			int bytesRead = fileInputStream.read(buffer, 0, bytesAvailable);

			while (bytesRead > 0) {
				dos.write(buffer, 0, bytesAvailable);
				bytesAvailable = fileInputStream.available();
				bytesAvailable = Math.min(bytesAvailable, maxBufferSize);
				bytesRead = fileInputStream.read(buffer, 0, bytesAvailable);
			}

			// send multipart form data necesssary after file data...
			dos.writeBytes(lineEnd);
			dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

			// close streams
			fileInputStream.close();
			dos.flush();
			dos.close();
		} catch (IOException e) {
			...
		}

The Exception:

    07-24 14:48:43.280: E/App(5802): failed to upload file '/mnt/sdcard/somefile.xml' to   
    server 'http://192.168.x.xxx:80/index.php'
    07-24 14:48:43.280: E/App(5802): java.net.ConnectException: /192.168.x.xxx:80 -   
    Connection refused

