Scientists have finally answered a question that has confounded mankind for ages: What happens if you get an octopus high on ecstasy and introduce it to Chewbacca?

Johns Hopkins University School of Medicine announced Thursday that its researchers were able to unravel that mystery with an experiment that involved putting drugged-up octopuses in an environment that was part underwater Coachella and part sci-fi convention.

After the scientists dosed the sea creatures with MDMA by placing them in a solution saturated with the drug, the octopuses were allowed to swim in a tank with three chambers — one empty, another holding a different octopus in a cage, and a third containing a small action figure, such as Chewbacca from “Star Wars.”

The researchers observed just how friendly the molly-addled mollusks got, and say the results are clear: MDMA makes octopuses as cuddly as any 1990s raver.

Octopuses are normally solitary — but during the experiment, they got very touchy-feely with their fellow octopus in a cage.

“They tended to hug the cage and put their mouth parts on the cage,” said the study’s lead investigator, Gül Dölen. “This is very similar to how humans react to MDMA.”

The creatures spent time with Chewie only during control tests, when they didn’t get any drug doses.

Scientists say the experiment provides an understanding of how serotonin affects social interaction.

“The brains of octopuses are more similar to those of snails than humans, but our studies add to evidence that they can exhibit some of the same behaviors that we can,” Dölen said.

One of the difficulties the researchers faced was figuring out how much ecstasy to give the California two-spot octopuses.

At first, the scientists used too high a dose and the animals “freaked out and did all these color changes,” Dölen said.

Once the dose was dialed down, researchers placed the creatures in the special tank and just watched them go.

“Despite anatomical differences between octopus and human brain, we’ve shown that there are molecular similarities in the serotonin transporter gene,” Dölen said.

The study was published in the journal scientific Current Biology.

It was unclear if any tax money was used to fund the study.