can't upload sketch to arduino yun over usb or wifi

i dont know what happens for my arduino yun, when i try to upload sketch over usb, there is error says cant find port!

when i plug in my arduino yun to my PC via usb, and from the IDE, i can choose the port, but when i upload the sketch, the arduino yun disconnect from my PC. and IDE shows error, so i close the IDE and open it again, the arduino yun connect to PC again and you can also find the port, but the port number changes.

but i can upload sketch via wifi sometimes, however after upload it successfully, i cant go to address like http://arduino.loacl/arduino/sketchname, it will show: Could not connect to YunServer 146 Connection refused, and another thing happen, i can go to address: http://arduino.local/sd/sketchname

so i think it maybe arduino part has problems, so, how to deal with it, anyone meet this?

also i find when i upload sketch via usb, besides it will disconnect from PC, it's l13 will be red and rx tx will flash

i find where the problem is, the bridge does not work!!! the sketch hangs on the

bridge.begin();

im still trying to find the way to solve it, and i find someone said:

alexafa:
Hello!

This is my solution.

Create a new file int ‘/etc/rc.d/’ named ‘K49stop-mcu’ (Scripts that run at shutdown)

#nano K49stop-mcu

Add this content:

#!/bin/sh

echo 18 > /sys/class/gpio/export
echo “high” > /sys/class/gpio/gpio18/direction
echo 1 > /sys/class/gpio/gpio18/value
echo 18 > /sys/class/gpio/unexport

Save, exit and change permissions:

chmod 7777 K49stop-mcu

It is done.

MCU stops before restarting and so the bridge does not fail booting Linino.

but i dont know how?