Pressure difference in bottles connected by pipe I was making a school project for my younger brother. Two bottles are taken and attached to each other using a pipe. To one bottle, the pipe is inserted almost at the bottom and the other almost at the middle of bottle. When i filled one bottle with water, at equilibrium, both the bottles had same height of water from ground.

However, I predicted that the water levels should be same in both the bottles not with respect to the ground, but to the point where pipes are attached to the bottles, i.e., the height of water columns above the point of attachment should be same. But the height in first bottle is more than that in the second bottle.
I think that the pressure should be same at both ends of the pipe at equilibrium and that pressure is $hρg$. Since the column height above pipe attachment is not same in both the bottles, the pressure at both ends should be different and water should still flow, which is not the case.
Where am I wrong?
 A: Since the column height above pipe attachment is not same in both the bottles, the pressure at both ends should be different and water should still flow, which is not the case.
Following on from your statement, if you fully immerse a straw vertically in a glass of water you would expect the water to flow into the bottom of the of the straw and out of the straw, which in fact does not happen.
There is indeed a pressure difference across the ends of the straw but at each position within the straw the net force acting at that point is zero.
Going back to the vertical straw in the water, the higher pressure of the liquid at the bottom of the straw produces a higher upward force on the liquid within the straw that the downward force produced by the lower pressure at the top of the straw.
Thus there is a net upward force on the body of water within the straw due to the pressure difference at the ends of the straw which is exactly equal in magnitude and oppose in direction to the gravitational force of attraction on that water due to the Earth - there is a static equilibrium situation.
And the net upward force on the body of water within the straw due to the pressure difference at the ends of the straw you might have heard by a different name - upthrust.
When I filled one bottle with water, at equilibrium, both the bottles had same height of water from ground.
This experimental result shows that your floor is level and variations on your device were used by ancient civilizations and even present day builders to try ensure foundations are level.
A: This is an excellent question because the answer seemingly defies common-physics-sense.
Wrzlprmft's answer clarifies that the connecting pipe can also be treated as a vessel. But that doesn't explain why the system is in equilibrium. Let me show you why.
Here an image can speak a thousand words.

The distances are labeled in standard font, and the labels in bold are pressures. Also, the pressure does not depend on the shape of the connecting pipe. You can see that the vessel pressure balances out the pressures at either end of the connecting pipe at the corresponding points. Hence, the system is in equilibrium.
Notice that $a$ and $b$ can be anything here. So no matter where you attach the pipe, this equilibrium condition will still hold.
A: The scenario of two bottles connected by a straw, is the same as a single container with a straw in it in any orientation.
In short:
The water pressure at each point within the straw is in equilibrium.
In Long:
The reason water does not continue to travel up (or down) the straw after the water levels of both bottles are of equal height, is because the pressure at the lower end of the straw is balanced between the water depth in that bottle, and the water depth in the other bottle - not just the water in the straw . There is water above the high end of the straw in the other bottle - that water matters.
In other words, the straw essentially makes the two bottles a single container.  And if, for example, you submerge a straw completely into just one container (bottle, tub, sink, or whatever),  once filled with water,  water does not continue to flow up the straw because the water pressure at each point within the straw is in equilibrium, just as the water at each point within the larger container is in equilibrium.
A: Thought experiment: Imagine removing one of the bottles and lifting the pipe above the water level in the remaining water bottle: Now there is certainly a pressure difference since one end is at air pressure and the other has the added effect of the water column.
Q: How high will the water rise in the pipe now?
A:

 Only as high as the water level in the bottle (disregarding capillary action).

The pressure at both end of the pipe does not need to be the same for there to be an equilibrium. In fact, there is even a pressure difference between any two heights in each bottle but no net flow within the bottles. What matters is that energy is conserved.
To transport a water molecule from the lower end of the pipe to the higher end, we need energy which needs to come from somewhere. In the non-equilibrium situation it comes from the decrease in the height of the water level in the bottle, i.e. the potential energy of the water with respect to ground level.
In the case pictured, if water were transported from one bottle to the other we would be creating energy out of nowhere. You can imagine a water molecule, originally at water level in the bottle on the left, transported through random thermal motion along the pipe into the other bottle. It cannot rise higher than its original height without added energy.
A: You have built some communicating vessels and fell victim to a variant of the hydrostatic paradox.
In communicating vessels, the water level is the same everywhere with respect to the ground.

I think that the pressure should be same at both ends of the pipe at equilibrium and that pressure is $hρg$.

This is where you made an error:
The pressure is not the same at both ends of the pipe.
Instead, since the pipe is a vessel as well, pressure increases when going from the top right to the bottom left, following the same law.

To see the effect you are hypothesising, you would need to do the following:

*

*Make the pipe sufficiently small that surface tension and adhesion (roughly the capillary effect) keep water from collecting at the bottom when the pipe is horizontal.


*Fill the pipe with air.


*Close off both ends of the pipe.


*Fill the containers to have the described water level with respect to the pipe end.


*Open the pipe ends.
Now, both ends of the pipe will have the same pressure and be in balance.
The key difference here is that air is much lighter than water and thus the build-up of pressure along the inclined pipe is negligible.
Note that on account of the increased pressure (with respect to the room), some water will enter the pipe on both sides until the air is compressed accordingly, which can help to straighten out minor inaccuracies with respect to fill level.
Still, preparing this experiment requires great accuracy.
